akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
int ans[100002];

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    ans[a]++;
    ans[a+1]++;
    ans[a+2]++;
  }
  int res = 0;
  for(int i = 0; i < 100002; i++){
    res = max(res, ans[i]);
  }
  cout << res << endl;
	return 0;
}


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

int main() {
  int a, b, res;
  cin >> a >> b;
  if ((a + b) % 2 == 0){
  	res = (a + b) / 2;
  } else {
  	res = (a + b) / 2 + 1;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
judge = 'APPROVED'
N = int(input())
Document = list(map(int, input().split()))
for i in range(len(Document)):
  if Document[i] % 2 == 0:
    if not(Document[i] % 3 == 0 or Document[i] % 5 == 0):
      judge = 'DENIED'
      break
print(judge)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

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

    double r; cin>>r;
    double ans = 2 * 3.141592 * r;
    cout<<setprecision(12)<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
long long dp[60][3][3];
int n;
string s[2];
const long long MOD=1000000007LL;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>s[0]>>s[1];
	if(s[0][0]!=s[1][0]){
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++)if(i!=j){
				dp[0][i][j]=1LL;
			}
		}
	}
	else{
		for(int i=0;i<3;i++){
			dp[0][i][i]=1LL;
		}
	}
	long long res=0;
	for(int i=0;i<n-1;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(s[0][i]==s[0][i+1])
					dp[i+1][j][k]+=dp[i][j][k];
				else if(s[0][i+1]==s[1][i+1]){
					for(int l=0;l<3;l++)if(l!=j&&l!=k){
						dp[i+1][l][l]+=dp[i][j][k];
					}
				}
				else{
					for(int l=0;l<3;l++)if(l!=j){
						for(int m=0;m<3;m++)if(m!=k&&l!=m){
							dp[i+1][l][m]+=dp[i][j][k];
						}
					}
				}
			}
		}
	}
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			res+=dp[n-1][i][j];
		}
	}
	cout<<res%MOD<<endl;
	return 0;
}
/*
52
RvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn
RLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn
*/

Measured memory_bytes: 892
import           Control.Monad
main = do
    [n, k] <- map read . words <$> getLine :: IO [Int]
    d <- filter (/= ' ') <$> getLine
    let x = [ i | i <- ['0'..'9'], i `notElem` d ]
    let l = length $ show n :: Int
    print $ g n l x
  where
    f n l = filter (n<=) . map (read :: String -> Int) . replicateM l
    g n l x =
        minimum $ case f n l x of
            [] -> f n (l+1) x
            _  -> f n l x


Measured memory_bytes: 1276
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;


void Solve() {
	string s; cin >> s;
	UL ans = 0;
	for (UL i = 0; i < s.size() / 2; i++) {
		if (s[i] != s[s.size() - i - 1]) ans++;
	}
	cout << ans << endl;
}

int main() {
	Solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if(x-r<0 || x+r>W || y-r<0 || y+r>H){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(std::string S, std::string T)
{

  int minim = S.size();
  for (int i = 0; i < S.size(); i++)
  {
    int cnt = 0;
    if (i + T.size() > S.size())
      continue;
    for (int j = 0; j < T.size(); j++)
    {
      if (S[i + j] != T[j])

        cnt++;
    }
    chmin(minim, cnt);
  }
  cout << minim << endl;
}

int main()
{
  cout << setprecision(10);
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  solve(S, T);
  return 0;
}


Measured memory_bytes: 3636
n = int(input()) 
s = []
t = []

for i in range(n):
	s.append(input())
  
m = int(input())

for i in range(m):
	t.append(input())
    
max = 0

for i in range(n):
	k = s.count(s[i]) - t.count(s[i])
	if max < k:
		max = k
        
print(max)  

Measured memory_bytes: 3064
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
#include <pthread.h>
#include <omp.h>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
#define _USE_MATH_DEFINES
using namespace std;
using namespace std::chrono;


int mod_power(int x, int y, int mod){
  int ans = 1;
  x %= mod;
  while(y){
    if (y & 1)
      ans *= x, ans %= mod;
    y /= 2;
    x = (x * x) % mod;
  }
  return ans;
}

int mod_inverse(int n, int mod){
  return mod_power(n, mod - 2, mod);
}

int mod_ncr(int n, int r, int mod){
  if (r == 0 or r == n)
    return 1;
  int fact = 1;
  for (int i = 1; i <= r; i++)
    fact *= i, fact %= mod;
  int ans = 1;
  for (int i = n; i > n - r; i--)
    ans *= i, ans %= mod;
  ans *= mod_inverse(fact, mod), ans %= mod;
  return ans;
}

unordered_map<int, int> factor(int n){
  int cnt = 0;
  unordered_map<int, int> m;
  int nn = n;
  while (!(nn & 1))
    cnt++, nn /= 2;
  if(cnt)
    m[2] = cnt;
  for (int i = 3; i <= sqrt(n); i++){
    cnt = 0;
    while(nn % i == 0)
      nn /= i, cnt++;
    if (cnt)
      m[i] = cnt;
  }
  if (nn > 2)
    m[nn] = 1;
  
  return m;
}



signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);

  string s, t;
  cin >> s >> t;
  unordered_map<int, Vi> m;
  for (int i = 0; i < s.size(); i++)
    m[s[i]].pb(i);
  bool could = true;
  for (int i = 0; i < t.size(); i++)
    if (m.find(t[i]) == m.end())
      could = false;

  if (not could){
    cout << -1 << endl;
    exit(0);
  }
  
  int cur = -1;
  int ans = 0;
  for (int i = 0; i < t.size(); i++){
    cur++;
    if (cur == s.size())
      cur = 0, ans++;
    int l = 0, r = m[t[i]].size() - 1;
    int pre_r, pre_l;
    while (l < r){
      pre_r = r, pre_l = l;
      int mid = (r + l) / 2;
      int mid_value = m[t[i]][mid];
      if (mid_value >= cur)
	r = mid;
      else
	l = mid;
      if (l == pre_l and r == pre_r)
	break;
    }
    if (m[t[i]][l] >= cur)
      cur = m[t[i]][l];
    else if (m[t[i]][r] >= cur)
      cur = m[t[i]][r];
    else
      cur = -1, ans++, i--; 
  }
  cout << ans * s.size() + cur + 1<< endl;
}


Measured memory_bytes: 4772
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    static void Main()
    {
        var s = Console.ReadLine();
        var counts = Enumerable.Range('a', 'z' - 'a' + 1).ToDictionary(c => (char)c, _ => 0L);
        foreach (var c in s)
        {
            counts[c]++;
        }

        var sum = counts.Sum(kv => kv.Value);
        var others = sum;
        var pattern = 1L;
        foreach (var kv in counts.Where(kv => kv.Value > 0))
        {
            pattern += kv.Value * (others - kv.Value);
            others -= kv.Value;
        }
        Console.WriteLine(pattern);
    }
}

Measured memory_bytes: 13368
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int dp[5010], dp2[25000010];

signed main() {
    int N;
    cin >> N;

    int a1, a2, a3, b1, b2, b3;
    cin >> a1 >> a2 >> a3 >> b1 >> b2 >> b3;

    REP(i, 1, N) {
        dp[i] = dp[i - 1] + 1;
        if (i >= a1) dp[i] = max(dp[i], dp[i - a1] + b1);
        if (i >= a2) dp[i] = max(dp[i], dp[i - a2] + b2);
        if (i >= a3) dp[i] = max(dp[i], dp[i - a3] + b3);
    }

    int M = dp[N];
    cerr << "M = " << M << endl;

    REP(i, 1, M) {
        dp2[i] = dp2[i - 1] + 1;
        if (i >= b1) dp2[i] = max(dp2[i], dp2[i - b1] + a1);
        if (i >= b2) dp2[i] = max(dp2[i], dp2[i - b2] + a2);
        if (i >= b3) dp2[i] = max(dp2[i], dp2[i - b3] + a3);
    }

    cout << dp2[M] << endl;

    return 0;
}


Measured memory_bytes: 195584
n,q=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
ans=[0]*n
for _ in range(q):
    p,x=map(int,input().split())
    ans[p-1]+=x
f=[1]*n
st=[0]
while st:
    v=st.pop()
    f[v]=0
    for u in g[v]:
        if f[u]:
            ans[u]+=ans[v]
            st.append(u)
print(*ans)

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define int long long
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl;
typedef long long ll;
typedef string str;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<P> VP;
const int INF = 1LL<<60;
const int MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c)cout<<"Yes";
  else cout<<"No";
  
  
  
  
  return 0;
}


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

const bool DEBUG = false;

string S;

void input() { cin >> S; }

int main(int argc, char const *argv[]) {
  input();
  int N = S.size();
  vector<int> anti;
  for (int i = 0; i < N - 1; i++)
    if (S[i] != S[i + 1]) anti.push_back(i);

  vector<long long> counts(N);

  int anti_pos;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'R') {
      // 自分より右側のanti positionを探す
      anti_pos = *(lower_bound(anti.begin(), anti.end(), i));
      counts[anti_pos + ((anti_pos - i) % 2)]++;
    } else {
      // 自分より左側のanti positionを探す
      counts[anti_pos + ((i - anti_pos) % 2)]++;
    }
  }

  for (size_t i = 0; i < N; i++) {
    cout << counts[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1912
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for(int i=0; i<n; i++) {
            int[] it = new int[3];
            it[0] = scanner.nextInt();
            it[1] = scanner.nextInt();
            it[2] = scanner.nextInt();
            Arrays.sort(it);
            if(it[0]*it[0] + it[1]*it[1] == it[2]*it[2]) {
                System.out.println("YES");
            }else {
                System.out.println("NO");
            }
        }
    }
}

Measured memory_bytes: 33204
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

string s;

int main() {
    cin >> s;
    ll cnt = 0;
    ll cnt2 = 0;
    REP(i,s.size()){
        if(s[i]=='W'){
            cnt2+=i-cnt++;
        }
    }
    put(cnt2);
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int n;
struct node{
    int c, v;
}a[N];
int main() {
    ios::sync_with_stdio(false); cin.tie(0) ;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i].v;
    for(int i = 1; i <= n; i++) cin >> a[i].c;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(a[i].v > a[i].c) ans += a[i].v - a[i].c;
    }
    cout << ans ;
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t  i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

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

  ll n,m;
  std::cin>>n>>m;

  std::vector<P> test(m);
  rep(i,0,m)std::cin>>test[i].first>>test[i].second;

  if(n==1){
    bool isok=true;
    for(auto e:test)if(e.second!=0)isok=false;
    if(isok){
      std::cout<<0<<"\n";
      return 0;
    }
  }

  rep(num,pow_mod(10,n-1),pow_mod(10,n)){
    ll temp=num;
    std::vector<ll> t(n);
    for(ll i=n-1;i>=0;i--){
      t[i]=temp%10;
      temp/=10;
    }
    bool isok=true;
    for(auto e:test){
      if(t[e.first-1]!=e.second)isok=false;
    }
    if(isok){
      std::cout<<num<<"\n";
      return 0;
    }
  }

  std::cout<<-1<<"\n";

  return 0;
}



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

using namespace std;

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

	int n;
	cin >> n;
	double a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a,a+n);
	double ans = (a[0]+a[1])/2;
	for(int i=2; i<n; i++){
		ans = (ans+a[i])/2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
#define int long long
 
#define check(c)       cout<<#c<<" : "<<c<<endl;
#define check2(a, b)    cout<<#a<<" : "<<a<<" | "<<#b<<" : "<<b<<endl;
#define check3(a, b, c)  cout<<#a<<" : "<<a<<" | "<<#b<<" : "<<b<<" | "<<#c<<" : "<<c<<endl;

void testCase(){
	  // int n; cin >> n;
	  // vector<int> a(n);

	   int a, b, c, d;
	   cin >> a >> b >> c >> d;
	   int ans = a * c;
	   ans = max(ans, a * d);
	   ans = max(ans, b * c);
	   ans = max(ans, b * d);
	   cout << ans << endl;

}
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int t = 1;
    // int t; cin >> t;
    while(t--)
        testCase();
    
    return 0;
}

Measured memory_bytes: 3648
import heapq

def prim(cost):
    V = len(cost)
    res = 0
    mincost = [float('inf')]*V
    used = [False]*V
    hq = []
    mincost[0] = 0
    heapq.heappush(hq,(0,0))
    while hq:
        weight,u = heapq.heappop(hq)
        if used[u]:
            continue
        used[u] = True
        res += weight
        mincost[u] = weight
        for v, v_cost in cost[u]:
            if not used[v]:
                heapq.heappush(hq,(v_cost,v))
    return res

N = int(input())
xyi = []
for i in range(N):
    x,y = map(int,input().split())
    xyi.append([x,y,i])

xyi.sort()
cost = [[] for _ in range(N)]
for i in range(N-1):
    xj = xyi[i][0]
    j = xyi[i][2]
    xk = xyi[i+1][0]
    k = xyi[i+1][2]
    cost[j].append((k,xk-xj))
    cost[k].append((j,xk-xj))
xyi.sort(key=lambda x:x[1])
for i in range(N-1):
    yj = xyi[i][1]
    j = xyi[i][2]
    yk = xyi[i+1][1]
    k = xyi[i+1][2]
    cost[j].append((k,yk-yj))
    cost[k].append((j,yk-yj))

print(prim(cost))


Measured memory_bytes: 82128
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int P, Q, R, res;
  rd(P);
  rd(Q);
  rd(R);
  res = P + Q + R -max_L(max_L(P, Q), R);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190609-2 [beta]

// --- original code ---
// {
//   int P, Q, R, res;
//   rd(P,Q,R);
//   res = P + Q + R - max(P, Q, R);
//   wt(res);
// }


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

int main(){
    char b;
    scanf("%c", &b);
    b == 'A' ?
        printf("T")
    :   b == 'T' ?
        printf("A")
    :   b == 'C' ?
        printf("G")
    :   b == 'G' ?
        printf("C")
    :   printf("Error");
}

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

int main() {
    int N; cin >> N;
    for (int i = 0; i < 50000; i++)
    {
       if((int) ((double) i * 1.08) == N){
           cout << i << endl;
           return 0;
       }
    }
    cout << ":(" << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, x, ans;
  cin >> n >> x;
  
  vector<ll> a(n);  
  rep(i, 0, n) {
    cin >> a[i];
    if(i == 0) ans = abs(x-a[i]);
    ans = __gcd(abs(a[i]-x), ans);
  }
  
  cout << ans << "\n";
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#define ll long long
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],b[n];
	int cnt=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	if(a[0]>1){
		cout<<-1<<endl;
	}else{
		int nn=n;;
		for(int i=0;i<nn;i++){
			for(int j=n-1;j>=0;j--){
				if(a[j]==j+1){
					b[cnt++]=a[j];
					for(int k=j;k<n-1;k++){
						a[k]=a[k+1];
					}
					n--;
					break;
				}
			}
		}
		if(cnt!=nn){
			cout<<-1<<endl;
		}else{
			for(int i=cnt-1;i>=0;i--){
				cout<<b[i]<<endl;
			}
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
// #define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// typedef long long ll;
#define REP(i, n) for (lli i = 0; i < (n); ++i)
#define FOR(i, a, b) for (lli i = (a); i < (b); ++i)
#define FORR(i, a, b) for (lli i = (b)-1; i >= (a); --i)
constexpr lli MOD = 1000000007ll;
// constexpr ll MOD=998244353ll;
constexpr lli MAX = 510000ll;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

lli fact[MAX], fact_inv[MAX];

// 繰り返し二乗法
lli power(lli a, lli b)
{
  lli res = 1LL;
  while (b > 0LL)
  {
    if (b & 1LL)
    {
      res = res * a % MOD;
    }
    a = a * a % MOD;
    b >>= 1LL;
  }
  return res;
}

lli comb(lli n, lli r)
{
  return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli b[200010LL] = {0}, c, h, k, n, w, ans = 0LL, tmp = 0LL, count = 0LL;
  string s, t;
  cin >> n;
  vlli a(n);

  fact[0] = 1LL;
  // 階乗の計算
  REP(i, n)
  fact[i + 1LL] = fact[i] * (i + 1LL) % MOD;
  fact_inv[n] = power(fact[n], MOD - 2LL);
  // 逆元の計算
  FORR(i, 0, n)
  fact_inv[i] = fact_inv[i + 1LL] * (i + 1LL) % MOD;

  rep(i, 0, n)
  {
    cin >> a[i];
    b[a[i] - 1LL]++;
  }
  rep(i, 0, n)
  {
    // cout << "b:" << b[i] << endl;
    if (b[i] >= 2LL)
    {
      ans += b[i] * (b[i] - 1) / 2;
    }
  }
  // cout << "ans:" << ans << endl;
  rep(i, 0, n)
  {
    tmp = ans;
    if (b[a[i] - 1] >= 2)
    {
      // lli diff = b[a[i] - 1] * (b[a[i] - 1] - 1) / 2;
      // cout << "diff:" << diff << endl;
      tmp -= b[a[i] - 1] * (b[a[i] - 1] - 1) / 2;
      tmp += (b[a[i] - 1] - 2) * (b[a[i] - 1] - 1) / 2;
    }
    cout << tmp << endl;
  }
}

Measured memory_bytes: 11392
/*  ex3_2
    ruuu0048 */
#include <stdio.h>
 
int main(void){
 
    int pencil_number,a_digit; //鉛筆の数とその数の一桁の変数を宣言
 
    scanf("%d",&pencil_number); //変数に鉛筆の数を入力する
 
    a_digit = pencil_number % 10; //鉛筆の一桁を計算し代入
 
    
    //条件分岐して助数詞を出力
    if(a_digit == 3){ //一桁目が3なら
        printf("bon\n");
    }
    else if(a_digit == 0 || a_digit == 1 || a_digit == 6 || a_digit == 8) //一桁目が0,1,6,8なら
    {
        printf("pon\n");
    }
    else //それ以外なら
    {
        printf("hon\n");
    }
    
 
    return 0; 
}


Measured memory_bytes: 1604
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
    char S[50];
    int K, N;
    scanf("%d %d", &N, &K);
    scanf("%s", S);
    if(S[K - 1] == 'A')
    {
        S[K - 1] = 'a';
    }else if(S[K - 1] == 'B')
    {
        S[K - 1] = 'b';
    }else{
        S[K - 1] = 'c';
    }
    printf("%s", S);
    return 0;
}

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

int main() {
  int n;
  int value=0;
  cin >>n;
  vector<int> v(n);
  for(int i=0; i<n;i++){
    cin >>v.at(i);
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());

  for(int i=0;i<n;i++){
    if(!(i%2))
      value+=v.at(i);
    if(i%2)
      value-=v.at(i);
  }
  cout << value <<endl;
}


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

int main() {
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    rep(i, k) {
        ans += p[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
import bisect
import heapq
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int,input().split()))
a_left = sorted(a[:N])
a_right = sorted(a[2*N:])
sum_left = sum(a_left)
sum_right = sum(a_right)
#res = sum_left - sum_right
res = sum_left - sum(sorted(a[N:])[:N])
a_right = [-elem for elem in a_right]
heapq.heapify(a_right)
heapq.heapify(a_left)
sr = [0]*(N+1)
sr[0] = sum_right

for i,elem in enumerate(reversed(a[N:2*N])):
    now = -heapq.heappop(a_right)
    if now > elem:
        heapq.heappush(a_right, -elem)
        sum_right += (elem-now)
    else:
        heapq.heappush(a_right, -now)
    sr[i+1] = sum_right

for i,elem in enumerate(a[N:2*N]):
    now = heapq.heappop(a_left)
    if now < elem:
        heapq.heappush(a_left, elem)
        sum_left += (elem-now)
    else:
        heapq.heappush(a_left, now)
    res = max(res, sum_left-sr[N-i-1])
print(res)


Measured memory_bytes: 118208
#include<cstdio>
#include<cstring>
int main(void){
	char s[100];
	char t[100];
	char c;
	int n,m;
	int i,j;
	scanf("%s",s);
	scanf("%s",t);
	n=strlen(s);
	m=strlen(t);
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(s[i]>s[j]){
				c=s[i];
				s[i]=s[j];
				s[j]=c;
			}
		}
	}
	for(i=0;i<m-1;i++){
		for(j=i+1;j<m;j++){
			if(t[i]<t[j]){
				c=t[i];
				t[i]=t[j];
				t[j]=c;
			}
		}
	}
	if(strcmp(s,t)<0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)



int main() {
	ll n,p;
	string s;
	map<string, vector<pair<ll, ll>>> dic;
	pair<ll, ll> tmpPair;

	in(n);
	rep(i, 0, n) {
		in(s);
		in(p);
		tmpPair.first = p;
		tmpPair.second = i + 1;
		dic[s].push_back(tmpPair);
	}
	
	for (auto itr = dic.begin(); itr != dic.end();itr++) {
		auto tmp = itr->second;
		sort(tmp.begin(), tmp.end(),greater<pair<ll,ll>>());
		rep(i, 0, tmp.size()) {
			outn(tmp[i].second);
		}
	}


	return 0;

}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int count;
  int i;
  for(i=0;i<3;i++) {
    if (s[i] == '1') {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let (n, a, b): (usize, usize, usize) = read();

    let mut count = 0;
    for x in 1..n+1 {
        let ds = digit_sum(x);
        if a <= ds && ds <= b {
            count += x;
        }
    }
    println!("{}", count);
}

fn digit_sum(a: usize) -> usize {
    let s = format!("{}", a).into_bytes();
    let mut total = 0;
    for u in s {
        total += (u - b'0') as usize;
    }
    total
}

Measured memory_bytes: 4352
import sys
N = int(input())
N2 = N
while(N >= 0):
  if N%4 == 0 or N%7 == 0:
    print('Yes')
    sys.exit()
  else:
    N -=4
while(N >= 0):
  if N%4 == 0 or N%7 == 0:
    print('Yes')
    sys.exit()
  else:
    N -=7
print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

#ifdef MY_DEBUG_FLAG
template<typename T> void debug(T a) { cerr << a << ' '; }
template<typename T, typename U> void debug(pair<T, U> a) { cerr << a.first << ' ' << a.second << ' '; }
template<typename T> void debug(vector<T> a) { for(auto it : a) debug(it);}
template<typename T> void debug(set<T> a) { for(auto it : a) debug(it);}
#define db(a) cerr << "DEBUG ( " << #a << " == "; debug(a); cerr << ")\n"
#else
#define db(...)
#endif

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false), cout.tie(nullptr), cin.tie(nullptr)
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define dec(i,n,a) for(int i=(n); i>=(a); i--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()

constexpr int inf = 0x3f3f3f3f;
constexpr int MAXN = 4e5 + 10;
constexpr int mod = 1000000007;

ll power(ll b, int e) {
	ll ans = 1;
	while(e) {
		if(e&1) ans *= b, ans %= mod;
		b *= b;
		b %= mod;
		e >>= 1;
	}
	return ans;
}

ll inv(ll x) { return power(x, mod-2); }

ll fat[MAXN];

void calc() {
	fat[0] = 1;
	rep(i,1,MAXN) fat[i] = fat[i-1]*i%mod;
}

ll choose(int a, int b) {
	return (((fat[a] * inv(fat[b]))%mod) * inv(fat[a-b]))%mod;
}

int main() {
	calc();
	int h, w, n; scanf("%d %d %d", &h, &w, &n);
	vector<pii> a(n);
	rep(i,0,n) scanf("%d %d", &a[i].ss, &a[i].ff);
	sort(a.rbegin(), a.rend());

	vector<ll> dp(n);
	for(int i = 0; i < n; i++) {
		int x = a[i].ff, y = a[i].ss;
		dp[i] = choose(w-x + h-y, w-x)%mod;

		for(int j = 0; j < i; j++) {
			if(a[j].ss >= y) dp[i] -= (dp[j]*
				choose(a[j].ff - x + a[j].ss - y, a[j].ff - x))%mod, 
				dp[i] %= mod;
		}
		if(dp[i] < 0) dp[i] += mod;
	}

	ll ans = choose(w-1 + h-1, w-1);
	for(int i = 0; i < n; i++) {
		int x = a[i].ff, y = a[i].ss;
		ans -= choose(x-1 + y-1, x-1)*dp[i]%mod;
		if(ans < 0) ans += mod;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 6944
import math
x,y=map(int,input().split())

mod = 10**9+7
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]


def init(n):
  for i in range(2, n + 1):
    fac.append(fac[-1] * i % mod)
    inv.append(-inv[mod % i] * (mod // i) % mod)
    finv.append(finv[-1] * inv[-1] % mod)


def com(n, k, mod):
    if n < 0 or k < 0 or n < k:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod

def main():
  if (x+y)%3:
    print(0)
    exit(0)
  else:
    n=(2*y-x)//3
    m=(2*x-y)//3
    if n<0 or m<0:
      print(0)
      exit(0)
    else:
      init(n+m)
      print(com(n+m,n,mod))
      
main()

Measured memory_bytes: 88076
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    int A,  B, C;
    cin >> A >> B;
    if(A % 2 && B % 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
from operator import itemgetter
from heapq import heappop, heappush
input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
MOD = 10**9 + 7

N = int(input())
A = sorted(inpl())
DP = [0]*60
B = [pow(2, i, MOD) for i in range(60)]

for i in range(N):
    a = A[i]*1
    
    for j in range(60):
        DP[j] += a&1
        a //= 2

ans = 0
for i in range(N):
    a = A[i] * 1
    for j in range(60):
        DP[j] -= a&1
        if a&1:
            ans = (ans + B[j]*(N-1-i-DP[j]))%MOD
        else:
            ans = (ans + B[j]*(DP[j]))
        a //= 2

print(ans%MOD)

Measured memory_bytes: 123084
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	cout << (N + 1) / 2 << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
k = gets.chomp.to_i

$cache = Array.new()
(k+1).times do |i|
  $cache << Array.new(k+1, 0)
end

def my_gcd (a, b)
  a,b = [b,a] if b<a
  if $cache[a][b] != 0
    return $cache[a][b]
  end
  $cache[a][b] = a.gcd(b)
  return $cache[a][b]
end

sum =0
(1..k).each do |i|
  (1..k).each do |j|
    (1..k).each do |l|
      #sum += my_gcd(my_gcd(i,j),l)
      sum += i.gcd(j).gcd(l)
    end
  end
end

puts sum


Measured memory_bytes: 14668
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>

using namespace std;
typedef long long ll;

#define MAX_N 1000000
#define INF 1000000

string a[MAX_N];

int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  set<string> st;
  map<string, int> mp;
  
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    //st.insert(a[i]);

    if ( mp.find(a[i]) != mp.end() ) mp[a[i]]++;
    else mp[a[i]] = 1;
      
  }

  // ---------------------
  // 
  int max_cnt = 0;

  /*
  for(auto itr = mp.begin(); itr != mp.end(); itr++) {
    cout << itr->first << " " << itr->second << endl;
  }
  */

  for(auto itr = mp.begin(); itr != mp.end(); itr++) {
    max_cnt = max(max_cnt, itr->second);
  }

  for(auto itr = mp.begin(); itr != mp.end(); itr++) {
    if(itr->second == max_cnt) cout << itr->first << endl;
  }
    
  return 0;
  
}


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

int main(){
  int d,m;
  int count = 0;
  cin>>m>>d;
  for(int i=1;i<=m;i++){
  	for(int j=22;j<=d;j++){
      if(j%10>=2 && j/10>=2 && (j%10)*(j/10)==i){
      		count++;
      }
  	}
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll d;cin>>d;
    vector<ll>c(26);
    rep(i,26)cin>>c[i];
    vector<vector<ll> >s(d,vector<ll>(26));
    rep(i,d){
        rep(j,26)cin>>s[i][j];
    }
    vector<ll>last(26);
    vector<ll>v(d);
    ll ans=0;
    rep(i,d){
        ll ma=-inf*inf;
        ll idx=0;
        rep(t,26){
            ll cn=0;
            cn+=s[i][t];
            cn+=6*c[t]*(i-last[t]+1);
            if(cn>ma){
                ma=cn;
                idx=t;
            }
        }
        last[idx]=i+1;
        v[i]=idx+1;
    }
    rep(i,d){
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int x, y;

int main() {
    cin >> x >> y;
    bool flg = false;
    for(int i = 0; i <= x; ++i) {
        int kame = i*2;
        if((y-kame)%4 == 0) {
            if((y-kame)/4 == x-i) {
                flg = true;
                break;
            }
        }
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll N,M;
  cin>>N>>M;
  vector<P> v(M);
  ll a,b;
  FOR(i,0,M){
    cin>>a>>b;
    v[i]=make_pair(a,b);
  }
  sort(v.begin(),v.end());

  int posi=0;
  int res=1;
  FOR(i,1,M){
    if(v[posi].second<=v[i].first){
      posi=i;
      res++;
      //cout<<i<<endl;
    }
    if(v[posi].second>=v[i].second){
      posi=i;
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 1920
n = gets.to_i
a = gets.split.map(&:to_i)

def f(a, x, y)
  a[y] += a[x]
  puts [x + 1, y + 1] * " "
end

p n * 2
amax = a.max
amin = a.min
# p amax
# p amin
if amax.abs >= amin.abs
  prev = a.index(amax)
  n.times do |i|
    f(a, prev, i)
    # prev = i
    # p a
  end
  # p a
  prev = a.index(a.max)
  n.times do |i|
    f(a, prev, i)
    prev = i
  end
else
  prev = a.index(amin)
  (n - 1).downto(0) do |i|
    f(a, prev, i)
    # prev = i
  end
  prev = a.index(a.min)
  (n - 1).downto(0) do |i|
    f(a, prev, i)
    prev = i
  end
end

# p a


Measured memory_bytes: 1788
#include <cstdio>

using namespace std;

int main(){
  int N, X;
  int mini = 1000000;
  int ans = 0;
  
  scanf("%d%d", &N, &X);
  for(int i = 0; i < N; i++){
    int a;
	scanf("%d", &a);
    X -= a;
    ans += 1;
    if(a < mini)
      mini = a;
  }
  ans += X / mini;
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

typedef long long int lli;

using namespace std;

int main() {

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

   vector<pair<int,int>> path;
   int a,b;
   for(int i=0;i<M;i++){
      cin >>a >>b;
      path.push_back({a-1,b-1});
      path.push_back({b-1,a-1});
   }
   sort(path.begin(),path.end());

   int B[N],C[N];
   for(int i=0;i<N;i++ ){
      B[i]=0;
      C[i]=0;
   }

   for(int i=0;i<M*2;i++){
      B[path[i].first]+=1;
      C[path[i].first]+=(A[path[i].first]>A[path[i].second]?1:0);
   }
   int sum=0;
   for(int i=0;i<N;i++){      
      if(B[i]==C[i]){
         sum++;
      }
   }
   cout << sum << endl;

}

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

int main() {
    char s[10000]={};
    int n,ok=1;
   /// cin>>s; ///daca nu contine spatii
    cin.getline(s,10000);
    n=strlen(s);/// returneaza cate caractere ai in sir
    ///122131221 n=9 (5,8), (6,7)
    ///012345678
    
    ///akaxaka    (0,6),(1,5),(2,4)
    ///0123456
    
    for(int i=0;i<n/2;i++){ 
        if(s[i]!=s[n-i-1]) ok=0;                
    }
    //cout<<ok<<"1\n";
    int m=(n-1)/2;
    for(int i=0;i<(n-1)/4-1;i++){
        if(s[i]!=s[m-i-1]) ok=0;
    }
    //cout<<ok<<"2\n";
    //cout<<n/2+1<<" "<<n/2+1+n/4-1<<" "<<n<<endl<<endl;
    for(int i=n/2+1;i<=n/2+1+n/4-1;i++){
      //  cout<<i<<" "<<n-i-1+(n/2+1)<<endl;
        if(s[i]!=s[n-i-1+(n/2+1)]) ok=0;
    }
    //cout<<ok<<"3\n";
    if(ok==0) cout<<"No";
    else      cout<<"Yes";
 return  0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

inline void YESNO(bool ans){cout<<(ans?"YES":"NO")<<endl;}
inline void YesNo(bool ans){cout<<(ans?"Yes":"No")<<endl;}
inline void yesno(bool ans){cout<<(ans?"yes":"no")<<endl;}

int main(){
	string s;
	cin>>s;
	
	llong sum=0LL;
	REP(i,s.size()) sum+=(s[i]-'0');
	
	bool ans=(sum%9==0);
	
	YesNo(ans);
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
const int MOD =(int)(1e9)+7;
int main()
{
    int N;
    cin >> N;
    vector<int>a(N);
    for(int i=0;i<N;i++)cin >> a[i];
    map<int,int>pos;
    for(int i=N-1;i>=0;i-=2){
        if(i==0)pos[i]=1;
        else pos[i]=2;
    }
    int ans=1;
    for(int p : a){
        pos[p]--;
        if(pos[p]<0){
            cout << 0 << endl;return 0;
        }
        if(pos[p]==0&&p!=0){
            ans*=2;
            ans%=MOD;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2944
n = input()
le = len(n)
s  = 0

for i in range(2 ** (le-1)):
    l = [""] * (le-1)
    for j in range(le):
        if i >> j & 1:
            l[j] = "+"
    
    f = ""
    for j, k in zip(n, l + [""]):
        f += (j + k)
        
    s += eval(f)

print(s)

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

int main(void) {
 while(1) {
   int H {0};
   int W {0};
   cin >> H >> W;

   if (H == 0 && W == 0) {
       break;
   }

   for(int i = 0; i < H; i++){
     for(int j = 0; j < W; j++){
       cout << "#";
     }
     cout << "\n";
   }
   cout << "\n";
 }
 return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

const int INF = 1e9;

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

    int N;
    cin >> N;
    vector<int> V(N+1), W(N+1);
    for (int i = 1; i <= N; i++) cin >> V[i] >> W[i];
    int MAX_L = 1e5;
    vector<vector<int>> dp(min(1 << 9, N+1), vector<int>(MAX_L+1));
    for (int i = 1; i < min(1 << 9, N + 1); i++) {
        dp[i] = dp[i / 2];
        for (int j = W[i]; j <= MAX_L; j++) {
            dp[i][j] = max(dp[i][j], dp[i / 2][j - W[i]] + V[i]);
        }
    }
    int Q;
    cin >> Q;
    REP(q, Q) {
        int v, L;
        cin >> v >> L;
        int ans = 0;
        if (v < (1 << 9)) {
            ans = dp[v][L];
        } else {
            vector<pair<int, int>> vals;
            vals.push_back({0, 0});
            while (v >= (1 << 9)) {
                vector<pair<int, int>> tmp;
                for (auto& p : vals) {
                    tmp.push_back({p.first + W[v], p.second + V[v]});
                }
                vals.insert(vals.end(), ALL(tmp));
                v /= 2;
            }
            for (auto& p : vals) {
                if (p.first > L) continue;
                ans = max(ans, dp[v][L - p.first] + p.second);
            }
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 206440
from bisect import bisect_right, bisect_left

N = int(input())

As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

ans = 0

for B in Bs:
    A_idx = bisect_left(As, B)
    C_idx = bisect_right(Cs, B)
    ans += A_idx * (N - C_idx)

print(ans)

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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}




int main()
{
    ll K,N;

    cin >> K >> N;

    ll A[N],max=-1;

    rep(i,N) cin >> A[i];


    rep(i,N-1){
        if(max<abs(A[i]-A[i+1])) max = abs(A[i]-A[i+1]) ;
    } 

    if(max<A[0]+K-A[N-1]) max =A[0]+K-A[N-1];

    cout << K-max <<endl;

 
    return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Mar 22 21:00:13 JST 2020
 **/

signed main() {
    Int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
	
	int coin[6]={500,100,50,10,5,1},price,sum;
	while(cin>>price,price){
		sum=0;
		price=1000-price;
		for(int i=0;i<6;i++){
			while(price>=coin[i]){
				price=price-coin[i];
				sum++;
			}
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 0