akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

bool is_uniq(string t) {
  t.erase(std::unique(t.begin(), t.end()), t.end());
  return t.size() == 1;
}

int solve(string s, char ch) {
  rep(i, inf) {
    string t;
    rep(j, s.size() - 1) {
      if (s[j] == ch) {
        t.push_back(s[j]);
      } else {
        t.push_back(s[j + 1]);
      }
    }
    if (is_uniq(t)) {
      return i + 1;
    }
    s = t;
  }
  assert(false && "fuck");
}

int main() {
  string s; cin >> s;
  if (is_uniq(s)) { cout << "0\n"; exit(0); }
  int ans = inf;
  rep(chi, 26) {
    auto ch = char('a' + chi);
    minimize(ans, solve(s, ch));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int gcd(int p,int q,int r);
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,i,j,k,sum=0;
    cin>>n;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            for ( k= 1; k<=n;k++) {
                sum+=gcd(i,j,k);
            }
        }
    }
    cout<<sum<<endl;
}
int gcd(int p,int q,int r){

        int a,b,c,hcf,st;
        a=p;
        b=q;
        c=r;

        st=a<b?(a<c?a:c):(b<c?b:c);

        for (hcf=st;hcf>=1;hcf--)
        {
            if (a%hcf==0 && b%hcf==0 && c%hcf==0)
                break;
        }

    return  hcf;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


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

int main()
{
	int a,b;cin >> a >> b;
	int ans = 0;
	for(int i = a;i <= b;i++){
		int tmp = i;
		string str = "";
		while(tmp){
			str += (char)((tmp%10)+'0');
			tmp /= 10;
		}
		bool flag = true;
		REP(j,str.size()){
			if(str[j] != str[str.size() - 1 - j])flag = false;
		}
		
		if(flag)ans++;
	}
	
	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())
b = list(map(int,input().split()))
cord = [list(map(int,input().split())) for c in range(N)]
ans = 0
for c in cord:
	tmp = 0
	for i in range(M):
		tmp += b[i] * c[i]
	if tmp + C > 0:
		ans += 1
print(ans)

Measured memory_bytes: 3060
N, A = gets.split.map(&:to_i)

X = gets.split.map{ |i| i.to_i.-A }.sort.reverse

max = 0
X.each do |x|
  max += x if x > 0
end

dp = Array.new(N+1){ Array.new( max + 1, 0 ) }

dp[0][0] = 1

X.each_with_index do |x,i|
  
  dp[i].each_with_index do |d,j|
    
    dp[i+1][j] = dp[i][j]
    dp[i+1][j] = dp[i][j] + dp[i][j-x] if ( 0<=j-x and j-x<=max)
    
    
  end
end

puts dp[N][0] - 1


Measured memory_bytes: 2812
#!/usr/bin/env python
# -*- coding: utf-8 -*-

A, B, C, X = [int(input()) for _ in range(4)]

count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X == i*500 + j*100 + k*50:
                count += 1
print(count)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <utility>
#include <string>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; i++)
#define INF (1<<30)

typedef long long ll;

using namespace std;

void solve(){
    double a, b, C;
    double S, L, h;

    cin >> a >> b >> C;

    S = 0.5 * a * b * sin(M_PI/(180.0/C));
    L = sqrt(pow(a, 2)+pow(b, 2)-2*a*b*cos(M_PI/(180.0/C)))+a+b;
    h = S/a*2;

    cout.precision(15);
    cout << fixed;
    cout << S << endl;
    cout << L << endl;
    cout << h << endl;
}

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


Measured memory_bytes: 3496
from collections import defaultdict


def main():

    n = int(input())

    v = list(map(int, input().split(' ')))

    odd = defaultdict(int)
    even = defaultdict(int)
    odd[0] = 0
    even[0] = 0

    for i, num in enumerate(v):
        # print(i % 2)
        if (i % 2) == 0:
            even[num] += 1
        elif (i % 2) == 1:
            # print(i, ": ", num)
            odd[num] += 1

    even_list = sorted(even.items(), key=lambda x: x[1], reverse=True)
    odd_list = sorted(odd.items(), key=lambda x: x[1], reverse=True)

    ans_list = []
    for ev in even_list[:2]:
        for od in odd_list[:2]:
            if ev[0] != od[0]:
                ans = 0
                ans += n - (ev[1] + od[1])
                ans_list.append(ans)

    print(min(ans_list))


main()


Measured memory_bytes: 21140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll>>;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

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

int main() {
    int n;cin >> n;
    int a = n%10;
    if(a==2 || a == 4 || a == 5 || a == 7 || a == 9){
	cout << "hon" << endl;
    }else if(a == 3){
	cout << "bon" << endl;
    }else{
	cout << "pon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
int main()
{
 
  int stack[100];
  char str[100];
  int top=0,i;
  int ch;
  for (i=0;i<100;i++){
    stack[i]=0;
  }
  while (scanf("%s",str)!=EOF){
    if (str[0]=='+'){
      stack[top-2]=stack[top-2]+stack[top-1];
      top=top-1;
    }else if(str[0]=='*'){
      stack[top-2]=stack[top-2]*stack[top-1];
      top=top-1;
    }else if(str[0]=='-'){
      stack[top-2]=stack[top-2]-stack[top-1];
      top=top-1;
    }else{
      stack[top]=atoi(str);
      top++;
    }
  }
  printf("%d\n",stack[top-1]);
  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
vector<string> forsubs;
ll ans=1000000000000;
ll n;

	

int main()
{    
 

	#ifdef APNA_IO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

ll n,m,b;
ll a[100005];
se s1;
ll mod=1000000007;


cin>>n>>m;

for(ll i=1;i<=m;i++)
	{
		cin>>b;
		s1.insert(b);
		
	}	

	a[0]=1;
	
	if(s1.find(1)!=s1.end())
		a[1]=0;
	else
		a[1]=1;

for(ll i=2;i<=n;i++)
	{
		if(s1.find(i)!=s1.end())
			a[i]=0;
		else
			a[i]=a[i-1]+a[i-2];
			
			
			a[i]=a[i]%mod;
		//cout<<a[i]<<endl;
	}

cout<<a[n]%mod<<endl;
}		





Measured memory_bytes: 8064
#include <bits/stdc++.h>
// OURL: https://atcoder.jp/contests/abc127/tasks/abc127_b

using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

int main(int argc, char *argv[]) {
  ll r,d,x;
  cin >> r >> d >> x;
  REP(i,10) {
    x = r*x - d;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;


int main(){
    int n, k, a = 0;
    string s;
    cin >> n >> k >> s;
    for (int i = 0; i < n - 1; i++){
        if (s[i] == s[i + 1])a++;
    }
    cout << min(k * 2 + a, n - 1) << endl;
}


Measured memory_bytes: 512
def resolve():
    data = []
    n,d = map(int,input().split())
    for _ in range(n):
        x = list(map(int,input().split()))
        data.append(x)
    square =[]
    for i in range(1,200):
        square.append(i*i)
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            k = [abs(l-m)**2 for l,m in zip(data[i],data[j]) ]
            s=sum(k)
            if s in square:
                ans = ans + 1

    print(ans)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 38480
from collections import deque
from copy import deepcopy
def factors(N):
    ret = []
    for i in range(2, int(N**(1/2))+1):
        if N%i == 0:
            ret.append([])
            t = 1
            while N%i == 0:
                N //= i
                ret[-1].append(i**t)
                t += 1
    return ret
N = int( input())
F = factors(N)
C = deque([1])

for d in F:
    T = deepcopy(C)
    for t in T:
        for s in d:
            C.append(t*s)

ans = 0
for c in C:
    m = N//c -1
    if m == 0:
        continue
    if N//m == N%m:
        ans += m

print(ans)


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

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

    int tower = 1000;
    vector<int> A(tower, 0);
    for (int i = 1; i < tower; i++) {
        A[i+1] += A[i] + i;
        if (i == b - a) {
            cout << A[i] - a << endl;
            return 0;
        }   
    }
}

Measured memory_bytes: 256
str = input()
for i in range(int(input())):
    process = input().split()
    a = int(process[1])
    b = int(process[2])
    
    if process[0] == 'replace':
        str = str[:a] + process[3] + str[b+1:]
    elif process[0] == 'reverse':
        str = str[:a] + str[a:b+1][::-1] + str[b+1:]
    elif process[0] == 'print':
        print(str[a:b+1])


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

long long int MOD;
vector<long long int> inverse;
vector<long long int> f, f_inverse;

void factorial_Initialize(int max){
    vector<long long int> a(max+1,1);
    inverse = a;
    f = a;
    f_inverse = a;

    for (int i=2; i<=max; i++){
        inverse[i]   = MOD - inverse[MOD % i] * (MOD / i) % MOD;
        f[i]         = f[i-1]         * i          % MOD;
        f_inverse[i] = f_inverse[i-1] * inverse[i] % MOD;
    }
}

long long int nCr(int n, int r){
    if(n < r || r < 0) return 0;
    if (n >= (int)f.size()){
        factorial_Initialize(n);
    }
    return f[n] * f_inverse[r] % MOD * f_inverse[n-r] % MOD;
}

int main(){
    int p;
    cin >> p;
    MOD = p;

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

    vector<long long int> ans(p);
    for(int i=0; i<p; i++){// [1 - (x-i)^{p-1}] * a[i]
        ans[0] += a[i];
        int phase = -1;
        long long int pow = 1;
        for(int j=p-1; j>=0; j--){
            ans[j] += phase * nCr(p-1, j) * pow * a[i];
            ans[j] = (ans[j] % MOD + MOD) % MOD;
            phase *= -1;
            pow *= i;
            pow %= MOD;
        }
    }

    for(int i=0; i<p; i++){
        cout << ans[i];
        if(i == p-1) break;
        cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
	ll N; cin >> N;

	ll open = 0;
	ll res = 1;
	const ll MOD = 1e9 + 7;
	FOR(i, 0, 2*N) {
		char c; cin >> c;
		ll val = c == 'B';

		if (open % 2 == val) {
			// r
			if (open <= 0) {
				res = 0;
				break;
			} else {
				res = (res * open) % MOD;
				open --;
			}
		} else {
			// l
			open ++;
		}
	}

	if (open != 0) res = 0;


	FOR(i, 2, N+1) {
		res = (res * i) % MOD;
	}

	cout << res << endl;
} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N >> S;
  if (N % 2 != 1 && S.substr(0, N / 2) == S.substr(N / 2, N / 2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

int main(){
  int dp[1001][1001];
  int n,m;
  cin >> n >> m;
  vector<int> c(m+1),d(n+1);
  for(int i = 1; i <= n; i++)cin >> d[i];
  for(int i = 1; i <= m; i++){
    cin >> c[i];
    dp[0][i] = 0;
  }
  dp[0][0] = 0;
  for(int i = 1; i <= n; i++){
    for(int j = 0; j <= m; j++){
      dp[i][j] = 200000000;
    }
  }
  for(int i = 1; i <= n; i++){
    for(int j = i; j <= m;j++){
      dp[i][j] = min(dp[i][j-1],dp[i-1][j-1]+c[j]*d[i]);

    }

  }
  cout << dp[n][m] << endl;
}



Measured memory_bytes: 6248
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
    }

    let mut cnt = 0;
    for a in 1..n {
        cnt += (n - 1) / a;
    }

    println!("{}", cnt);
}


Measured memory_bytes: 2164
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
#include <complex>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = acosl(-1.0);
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
		cout << 3;
	}
	else if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) {
		cout << 2;
	}
	else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
		cout << 1;
	}
	else {
		cout << 0;
	}
}

Measured memory_bytes: 3612
# https://atcoder.jp/contests/abc117/tasks/abc117_d
N, upper_bit = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
beki_ary = (1..39).to_a.each_with_object([1]) { |i, obj| obj << (obj.last * 2)}
already_min = false

ans = 0
39.step(0, -1) do |digest|
  mask = 1 << digest
  ones = A.count { |str| (str & mask) > 0 }
  if ones * 2 >= N
    already_min = true if upper_bit[digest] == 1
    ans += beki_ary[digest] * ones
  else
    if already_min || (upper_bit[digest] == 1)
      ans += beki_ary[digest] * (N - ones)
    else
      ans += beki_ary[digest] * ones
    end
  end
end
p ans


Measured memory_bytes: 8844
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    vector<int> abc(3, 0);
    
    cin >> abc[0] >> abc[1] >> abc[2];
    
    sort(abc.begin(), abc.end(), [](int a, int b) { return a > b; });
    
    cout << abc[0] * 10 + abc[1] + abc[2] << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::cmp::max;

type Cake = (i64, i64, i64);

fn input_tuple() -> (usize, usize) {
  let mut line: String = String::new();
  io::stdin().read_line(&mut line);
  let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
  (vec[0], vec[1])
}

fn input_tuple_three() -> (i64, i64, i64) {
  let mut line: String = String::new();
  io::stdin().read_line(&mut line);
  let vec: Vec<i64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
  (vec[0], vec[1], vec[2])
}

fn calc(c: [i64; 3], cake: &Cake) -> i64 {
  cake.0 * c[0] + cake.1 * c[1] + cake.2 * c[2]
}

fn main() {
  let (n, m) = input_tuple();
  let mut cakes: Vec<Cake> = Vec::new();
  for _ in 0..n {
    cakes.push(input_tuple_three());
  }
  let mut ans = 0;

  for bit in 0..1<<3 {
    let mut c = [1, 1, 1];
    for i in 0..3 {
      if bit & (1<<i) != 0 {
        c[i] = -1;
      }
    }
    let mut tmp = 0;
    cakes.sort_by(|x, y| calc(c, y).cmp(&calc(c, x)));
    for i in 0..m {
      tmp += calc(c, &cakes[i]);
    }
    ans = max(tmp, ans);
  }
  println!("{}", ans);
}

Measured memory_bytes: 4352
import sys
A,B = map(int,input().split())
S = list(input())
if S[A] != "-":
    print("No")
    sys.exit()
j = [str(i) for i in range(10)]
if len(S) != len([i for i in S if i in j and i != A])+1:
    print("No")
    sys.exit()
print("Yes")



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int x=0,f=1;
	while(c<'0'||c>'9'){ if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*f;
}
int a,b,c;
int main(){
	a=read(),b=read(),c=read();
	if(a%2==0||b%2==0||c%2==0){
		printf("0\n");
		return 0;
	}
	if(a>c) swap(a,c);
	if(b>c) swap(b,c);
	cout<<1ll*a*b<<endl;
	return 0;
}


Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
list_x = [int(i) for i in input().split()]
list_y = [int(j) for j in input().split()]
if max(list_x) >= min(list_y):
    print('War')
else:
    if X < max(list_x) + 1 <= Y:
        print('No War')
    else:
        print('War')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,ans=0;
bitset<4000010> f;
int main() {
    n=gi(),f[0]=1;
    for(int i=1,v;i<=n;i++) v=gi(),ans+=v,f|=f<<v;
    ans=(ans+1)/2;
    while(!f[ans]) ++ans;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1792
// AtCoder Beginner Contest 064
// A - RGB Cards

#include <cstdio>

using namespace std;
typedef long long int ll;


int main() {

    int r, g, b;

    scanf("%d%d%d", &r, &g, &b);

    printf("%s\n", (r * 100 + g * 10 + b) % 4 == 0 ? "YES" : "NO");

    return 0;

}





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

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ab(m);
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    ab.at(i) = make_pair(a, b);
  }
  
  sort(ab.begin(), ab.end());
  int ans = 1;
  int cut = ab.at(0).second;
  for(int i = 0; i < m; i++){
    int ka = ab.at(i).first, kb = ab.at(i).second;
    if(ka >= cut){
      cut = kb;
      ans++;
    }
    else cut = min(cut, kb);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var nw = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nw[0];
        var totalWeight = nw[1];

        var products = Enumerable.Repeat(0, (int)n).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).OrderByDescending(x => (double)x[0] / x[1]).ToArray();
        long res = 0;
        double fracRes = 0;
        foreach (var product in products)
        {
            var v = product[0];
            var w = product[1];
            if (totalWeight < w)
            {
                var additional = ((double)v / w) * totalWeight;
                res += (long)Floor(additional);
                fracRes = additional % 1;
                break;
            }
            res += v;
            totalWeight -= w;
        }
        Console.Write(res); Console.WriteLine(fracRes.ToString(".#############"));
    }
}


Measured memory_bytes: 33988
import java.util.*;


public  class Main {
		
	    Node head_node=new Node();
		Node tail_point=head_node;//尾指针
		Node current;//当前位置指针
		
		//插入节点
		public void same(String data) {
			//处理字符串
			String w;
			int sum=1;
			//添加进单链表
			for(int i=0;i<data.length();i++) {
				w=data.substring(i,i+1);
				Node temp=new Node(w);
				tail_point.next=temp;
				temp.next=null;
				tail_point=temp;
				
			}
			
			boolean flag=true;
			current=head_node.next;
			Node current1=current;
			Node current2=current.next;
			do {
				while(current2!=null) {	
					if(current.data.equals(current2.data)) {
						//如果同字符，sum就加一，并且将这个节点删除
						sum++;
						current1.next=current2.next;
						current2=current2.next;
						
					}else {
						//如果字符不相同，就节点向后移动
						current1=current1.next;
						current2=current2.next;
					}
				}
				if(sum%2==0) {
					
					if(current2==null&&current.next==null) {
						System.out.println("Yes");
						flag=false;
					}else {
						current=current.next;
						current1=current;
						current2=current.next;
						sum=1;
					}
				}else {
					flag=false;
					System.out.println("No");
				}
			}while(flag);
				
		}
		
		//处理相同的字符串
		
	public class Node {
		String  data;//数据域
		Node next;//指针域
		//节点构造
		public Node(String data) {
			this.data=data;
		}
		public Node() {
		
		}
			
	}
	
   
	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		Scanner sc=new Scanner(System.in);
	    String W=sc.nextLine();
	    Main B=new Main();
	    B.same(W);
	   
	}
}

	

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

int main(){
    int N,X,T; cin>>N>>X>>T;
    int a=N/X;
    if(N%X==0){
        cout<<a*T<<endl;
        return 0;
    }
    cout<<(a+1)*T<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

int main(void)
{
    int k, s;
    cin >> k >> s;
    int ans = 0;
    rep(x, 0, k + 1) rep(y, 0, k + 1) if (0 <= s - x - y && s - x - y <= k) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int max(int a, int b, int c)
{
	if (a >= b)
	{
		if (b >= c)
			return a;
		else if (c > b)
		{
			if (a >= c)
				return a;
			else return c;
		}
	}
	else
	{
		if (a >= c)
			return b;
		else if (c >= b)
			return c;
		else return b;
	}
}

int main(void)
{
	int a, b, c;
	int ans, wa;
	scanf("%d %d %d", &a, &b, &c);
	
	ans = max(a, b, c);
	if (ans == a) wa = b + c;
	if (ans == b) wa = a + c;
	if (ans == c) wa = a + b;
	
	if (ans == wa)
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}


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

int n;
long a[200000];
int main() {
  cin >> n;
  long sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum ^= a[i];
  }
  for (int i = 0; i < n; ++i) {
    cout << (sum ^ a[i]) << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 5184
#include<bits/stdc++.h>
#define F(i) for(int i=1;i<=n;++i)
int n; char str[305];
int a[305][305],Ans;
int main(){
	scanf("%d",&n);
	F(i){
		scanf("%s",str+1);
		F(j) a[i][j]=str[j];
	}
	F(k){
		int Ok=1;
		F(i) F(j){
			int I=(j-k-1+n)%n+1;
			int J=(i+k-1)%n+1;
			if(a[i][j]!=a[I][J]) Ok=0;
		}
		if(Ok) Ans+=n;
	} printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 640
N = int(input())
wl = []
for i in range(N):
    A, B = map(int, input().split())
    wl.append((A, B))

wl.sort(key=lambda x: x[1])

t = 0
for i in range(N):
    t += wl[i][0]
    if t > wl[i][1]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 31860
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c,d;
    char e;
  	string s;
  	cin>>a>>b>>c>>d;
	if(abs(b-a)<=d&&abs(b-c)<=d||abs(a-c)<=d)  
    cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())

using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
int modpow(int a,int n,int p){if (n==0)return 1%p; if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位


class unionfind{
public:
	vector<int> table;
	void init(int size){
		table.resize(size);
		rep(i,size)table[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(19);
	int d,t,s;
	in(d,t,s);
	int hoge=t*s;
	if(hoge>=d)out("Yes");
	else out("No");
	return 0;
}


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

int solve(string S, int D) {
	if (D < 0) return 0;

	int cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '1') cnt++;
	}
	if (cnt == S.size()) return cnt;
	if (cnt == 0) {
		if (D >= 1) return cnt;
		return 0;
	}

	vector<int> vec1, vec2;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '1' && (i == 0 || S[i - 1] == '0')) vec1.push_back(i);
		if (S[i] == '1' && (i == (int)S.size() - 1 || S[i + 1] == '0')) vec2.push_back(i + 1);
	}
	if (vec2.size() == 0) return 0;

	int maxn = 0;
	for (int i = 0; i < vec1.size(); i++) {
		int id = min((int)vec2.size() - 1, i + D);
		int c1 = vec1[i], c2 = vec2[id];
		maxn = max(maxn, c2 - c1);
	}
	return maxn;
}

int main() {
	string S; int K, N;
	cin >> N >> K >> S;

	string S1 = S; for (int i = 0; i < S.size(); i++) { if (S1[i] == '1') break; S1[i] = '1'; }
	string S2 = S; for (int i = S.size() - 1; i >= 0; i--) { if (S2[i] == '1') break; S2[i] = '1'; }
	string S3 = S1; for (int i = 0; i < S.size(); i++) { if (S3[i] == '1') break; S3[i] = '1'; }

	int r1 = solve(S, K);
	int r2 = solve(S1, K - 1);
	int r3 = solve(S2, K - 1);
	int r4 = solve(S3, K - 2);
	cout << max({ r1, r2, r3, r4 }) << endl;
	return 0;
}

Measured memory_bytes: 1536
k = int(input())
ls=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(ls[k-1])

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

#pragma warning(disable:4996)
using namespace std;



int main() {
	string st;cin>>st;
	int ans=0;
	int num=0;
	for (auto c : st) {
		if (c == 'L') {
			num--;
			if(num==-4)num=0;
		}
		else {
			num++;
			if (num == 4) {
				num=0;
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
} 


Measured memory_bytes: 3212
#include <stdio.h>
#include<string>
#include<string.h>
#include <math.h>
#include<iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
using namespace  std;


/*
//my header
#include "define.h"
#include "geometry.h"*/

#define MyAbs(a) ((a)>0?(a):-(a))
#define MyEqualDoule(a,b) (MyAbs(a-b)<1e-6)

void init()
{
#ifdef _WIN32
	freopen("1.txt", "r", stdin);
#endif
}

void func();

int main()
{
	init();
	func();

	return 0;
}


void func()
{
	int a,b,c,d,e,f;
	float x, y;
	while(~scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f))
	{
			x = (c*e-f*b)*1.0/(a*e - b*d);
			y = (c*d-a*f)*1.0/(b*d - a*e);
			float x2 = (c-b*y)*1.0/a;
			if(x-x2 != 0)
				while(1);
			if(MyEqualDoule(x, 0))
				x = 0;
		printf("%.3f %.3f\n", x, y);
	}
}

Measured memory_bytes: 1220
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int k = scan.nextInt();
		int x = scan.nextInt();

		for(int i=x-k+1;i<k+x;i++) {
			if(i < k+x-1) {
			System.out.println(i+" ");
			}else {
				System.out.println(i);
			}
		}
		scan.close();
	}

}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c,k;cin >> a >> b >> c >> k;
	if(k%2==0) cout << a-b << endl;
	else cout << b-a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100     
#define SUCCESS 1 // 成功
#define FAILURE 0 // 失敗
#define INFTY 1 << 21 // 到達不可能を表す大きな値

int queue[N]; // キューの本体
int queue_head = 0; // データ先頭
int queue_num; // データ個数

int node_num, M[N + 1][N + 1];
int d[N + 1]; // 距離で訪問状態(color)を管理する

int enqueue(int enq_data) // キューにデータを追加する
{
  if (queue_head + queue_num < N) {
    queue[queue_head + queue_num] = enq_data;
    queue_num++;
    return SUCCESS;
  } else {
    return FAILURE;
  }
}

int dequeue(int *deq_data) // キューからデータを取り出す
{
  if (queue_num > 0) {
    *deq_data = queue[queue_head];
    queue_num--;
    queue_head++;
    return SUCCESS;
  } else {
    return FAILURE;
  }
}

void bfs(int s) {
  enqueue(s); // 始点をキューに入れる
  for (int i = 1; i <= node_num; i++) d[i] = INFTY; // とりあえず全部INFTYにする
  d[s] = 0; // 始点から自分自身までの距離は0
  int u, p;
  while(queue_num > 0) { // キューが空でない間繰り返す
    u = queue[queue_head]; // キューの先頭からノードを取り出し，訪問
    dequeue(&p); // 同上
    for (int v = 1; v <= node_num; v++) {
        if (M[u][v] == 0) continue; // キュー先頭のノードとvが繋がってないならこのループは終了
        if (d[v] != INFTY) continue; // 既に距離を決めているならこのループは終了
        d[v] = d[u] + 1; // 次に訪問するノードまでの距離は，それまでの距離+1
        enqueue(v); // uに繋がっているノードは将来訪問しないといけない
    }
  }
  for (int i = 1; i <= node_num; i++) { // 表示部
    if (d[i] == INFTY) d[i] = -1;
    printf("%d %d\n", i, d[i]);
  }
}

// mainの流れはdfsと同じ(隣接行列の初期化→隣接行列にノード間の接続関係を登録→bfsを呼び出す)
int main(void)
{
  int u, v, k, i, j;
  
  scanf("%d", &node_num);
  for (i = 0; i <= node_num; i++) {
    for(j = 0; j <= node_num; j++) M[i][j] = 0;
  }

  for (i = 0; i < node_num; i++) {
    scanf("%d %d", &u, &k);
    for (j = 0; j < k; j++) {
      scanf("%d", &v);
      M[u][v] = 1;
    }
  }

  bfs(1);
  
  return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  ll n;
  cin>>n;
  ll count = 0;
  for(ll i=1;i<=n;i++){
    for(ll j=1;j<=n;j++){
      for(ll k=1;k<=n;k++){
        ll z = __gcd(i,j);
        z = __gcd(z,k);
        count = count + z;
      }
    }
  }
  cout<<count<<endl;
} 

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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl

ll maxpow(ll a){
    ll ans = 1;
    rep(i,a) ans *= 10;
    return ans;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    string s;
    cin >> s;
    vector<ll> mod(2019);
    int sum=0,order=1;

    rep(i,s.size()){
        sum = (sum + (int)(s.at(s.size()-i-1)-'0') * order) % 2019;
        mod[sum]++;
        order = (order * 10) % 2019;
    }
    ll ans=0;
    mod[0]++;
    rep(i,2019){
        ans += mod[i]*(mod[i]-1)/2;
    }

    print(ans);
    return 0;
}

Measured memory_bytes: 3760
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*
*   创 建 者： badcw
*   创建日期： 2019/12/29
*
================================================================*/
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int maxn = 100;
const int mod = 1e9+7;
ll qp(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <class T>
inline bool scan(T& ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return 0; // EOF
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

//template <class T>
//inline void out(T x) {
//    if (x > 9) out(x / 10);
//    putchar(x % 10 + '0');
//}

int main(int argc, char* argv[]) {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    //I don't care about anybody, and fuck ratings! I'll go to google!
    int a; cin>>a;
    bool ok = 0;
    for(int i = 1; i<=9; i++){
        for(int j = 1; j<=9; j++){
            if(i*j==a) ok = 1;
        }
    }
    cout<<(ok?"Yes\n":"No\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> m = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

string getmax(string a, string b)
{
  if(a.size() > b.size())
  {
    return a;
  }
  if(a.size() < b.size())
  {
      return b;
  }
  return a > b ? a : b;
}

int main()
{
    int n, M;
    cin >> n >> M;
    vector<int> a(M, 0);
    for(int i = 0; i < M; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    vector<string> dp(max(n + 1, 10), "");
    for(int i = 0; i < M; i++)
    {
        dp[m[a[i]]] = getmax(dp[m[a[i]]], to_string(a[i]));
    }

    for(int j = 0; j <= n; j++)
    {
        for(int i = 0; i < M; i++)
        {
            if(j - m[a[i]] >= 0 && dp[j - m[a[i]]] != "")
            {
                dp[j] = getmax(dp[j], dp[j - m[a[i]]] + to_string(a[i]));
            }
        }
    }
    cout << dp[n];

    return 0;
}


Measured memory_bytes: 32896
using System;

class Program
{
    static public void Main(string[] args)
    {
        string input = Console.ReadLine().Replace(" ", "");
        double num = int.Parse(input);

        num = Math.Sqrt(num);

        if (num == (int)num)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}


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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n, m;
  cin >> n >> m;
  int bigger = max(n,m);
  int smaller = min(n,m);
  REP(i,bigger) {
    cout << smaller;
  }
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])

prime = [1]
for i in range(2, math.ceil(g**0.5)+1):
  while g % i == 0:
    g /= i
    prime.append(i)
prime.append(g)
print(len(set(prime)))


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

#include <iostream>
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>


#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>



int getTheAnswer() {
    return 42;
}

template< class InputIt>
void incAll(const InputIt &first, const InputIt &last){
  for(auto it = first; it != last; ++it){
    ++*it;
  }
}

template <class InputIt>
void printAll(const InputIt &first, const InputIt &last, std::ostream& out){
  for(InputIt it = first; it != last; ++it){
    out << *it << " ";
  }
}

// only for positive integers
int gcd(int a, int b){
  int tmp;
  if(a < b){
    tmp = a;
    a = b;
    b = tmp;
  }
  while(b != 0){
    tmp = a;
    a = b;
    b = tmp % b;
  }
  return a;
}

int lcm(int a, int b){
  return abs(a*b) / gcd(a, b);
}


using namespace std;
class TaskC {
public:
	void solve(std::istream& in, std::ostream& out) {
    ios::sync_with_stdio(false);
		long long int n, m, res;
		in >> n >> m;
		res = min(n, m / 2);
		n -= res;
		m -= 2*res;
		res += m / 4;
		out << res << endl;
	}
};


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


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int main()
{
	long long n;
	cin>>n;
	vector<long long> v;
	long long x;
	long long sum=0;
	long long ms=1e9+7;
	for(long long i=0;i<n;i++)
	{
		cin>>x;
		v.emplace_back(x);
		sum+=x;
		sum%=ms;
	}
	long long s=0;
	long long ans=0;
	for(long long i=0;i<n;i++)
	{
		s+=v[i];
		s%=ms;
		ans+=(v[i]%ms*(sum%ms-s%ms+ms))%ms;
		ans%=ms;
	}
	cout<<ans<<"\n";
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    VI A(N), B(N), C(N-1);
    int ans = 0;
    REP(i,N) cin >> A[i];
    REP(i,N){
        cin >> B[i];
        ans += B[i];
    }
    REP(i,N-1) cin >> C[i];
    REP(i,N-1){
        if(A[i+1]-A[i] == 1){
            ans += C[A[i]-1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
a = int(S[0:2])
b = int(S[2:])

if 1 <= a <= 12 and a <= b <= 12:
  print("AMBIGUOUS")
elif 1 <= a <= 12:
  print("MMYY")
elif 1 <= b <= 12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 9156
function Main(input){
	var xs = input.trim().split('').map(v=>parseInt(v,10));
	var ans = 0;
    for(var i =0; i<xs.length; i++){
    	if(xs[i] == 1){
    	ans = ans+1;
    	}else{
    	ans = ans+0;
    	}
    }
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
package main

import	(
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	titles := make([]string,n)
	seconds := make([]int,n)

	for i := 0; i < n; i++ {
		fmt.Scan(&titles[i])
		fmt.Scan(&seconds[i])
	}
	
	var title string
	fmt.Scan(&title)
	
	sum := 0;
	start := false
	for i := 0; i < n; i++ {
		if start {
			sum += seconds[i]
		}
		if titles[i] == title {
			start = true
		}
	}
	fmt.Println(sum)
}

Measured memory_bytes: 512
global memo

def find_memo(m,l):#memoのm行l列の値を返す.data
                            #data[l]から続くm+1個の要素からなる部分リスト
    if(memo[m][l]!=0):
        return memo[m][l]
    
    if(m<2):
        return memo[m][l]
    

    tmp_min=999999999
    for i in range(1,m):
        left=find_memo(i,l)
        right=find_memo(m-i,l+i)
        middle=memo[0][l]*memo[0][l+i]*memo[0][l+m]
        if(left + right + middle< tmp_min):
            tmp_min = left + right + middle
    memo[m][l]=tmp_min
    return tmp_min




tmp_min=9999999999
n=int(input())
memo=[[0]*(n+1-i) for i in range(n+1)]#memo[i][j]はdata[j]から続くi+1個の要素からなる部分リストの最小計算コストを表す

memo[0][0],memo[0][1]=map(int,input().split())
for i in range(2,n+1):
    dummy,memo[0][i]= map(int,input().split())

for i in range(n-1):
    memo[2][i] = memo[0][i]*memo[0][i+1]*memo[0][i+2]

print(find_memo(n,0))



Measured memory_bytes: 5720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (auto &e : a)
    cin >> e;
  sort(a.begin(), a.end());

  if (a[n - 1] < k)
  {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  ll diff = a[0];
  for (int i = 1; i < n; ++i)
  {
    ll t = abs(a[i] - a[i - 1]);
    if (diff != t && t != 0)
      diff = min(diff, min(t, abs(t - diff)));
  }
  for (int i = 0; i < n; ++i)
  {
    if (a[i] < k || diff == 0)
      continue;
    if ((a[i] - k) % diff == 0 || a[i] == k)
    {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <cmath>
#include <iomanip>
#include <queue>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define ll long long
#define INF 1000000000

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

	int m[s.length()+1];

	REP(i,s.length()){
		m[i] =  26 - s[i] + 'a' ;
	}

	REP(i,s.length()){
		if(s[i] == 'a')continue;
		if(m[i]<=k){
			s[i] = 'a';
			k -= m[i];
		}
	}

	k%=26;

	for(int i=k;k>0;k--){
		if(s[s.length()-1]=='z'){
			s[s.length()-1] = 'a';
		}
		else s[s.length()-1] += 1; 
	}

	cout << s << endl;

	return 0; 

}

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

using namespace std;
typedef long long int lli;
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }

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

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        String[]  input1 = s.nextLine().split(" ");
        //1taps
        int A = Integer.valueOf(input1[0]);
        //min count
        int B = Integer.valueOf(input1[1]);

        int ct = 1;
        int hole = A;
        if (B != 1) {
            while(true) {
                if (hole >= B) break;
                ct++;
                hole += A-1;
            }
        } else {
            ct = 0;
        }

        System.out.println(ct);
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define pi 3.14159
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
int n, array1[100010];
bool checked[100010];
int main() {
    int i,j;
    scanf("%d",&n);
    for(i=0;i<n;++i){
        scanf("%d",&array1[i]);
    }
    int ans = 0;
    for(i=0;i<n;++i) {
        if(!checked[i]) {
        checked[i] = true;
        for(j=i+1;j<n;++j) {
            if(array1[j - 1] < array1[j])
                break;
            checked[j] = true;
            ans=max(ans,j-i);
        }
        }
    }
printf("%d",ans);
}


Measured memory_bytes: 768