akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define umapi unordered_map<ll, ll>
#define umapc unordered_map<char, int>
#define endl "\n"
using namespace std;
 
 
void solve()
{
    int n;
    cin>>n;

    string s;
    cin>>s;

    int cnt= 0;
    for(auto it : s) {
        if(it == 'R')   cnt++;
    }
    int ans = 0;
    for(int i=cnt; i<n; i++) {
        if(s[i] == 'R') ans++;
    }

    cout<<ans<<endl;
    
}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
  //  cin >> t;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
using ii = pair<ll, ll>;
#define ff first 
#define ss second
#define len(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define MAXN 100010

int main(){
	ios::sync_with_stdio(0);
	string st;
	cin >> st;
	int n = len(st);
	int ans = 0;
	for(int i=0; i<n/2; ++i)
		if(st[i]!=st[n-1-i]) ++ans;
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(true) {
        int h, w;
        cin>>h>>w;
        if(h==0 && w==0) break;
        for(int i=0; i<h; i++) {
            for(int j=0; j<w; j++) {
                if(i==0 || j==0 || i==h-1 || j==w-1) cout<<'#';
                else cout<<'.';
            }
            cout<<'\n';
        }
        cout<<'\n';
    }
    return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll N, K, ans;

int main()
{
    cin >> N >> K;
    vector<int> V(N);
    for (int i = 0; i < N; i++)
        cin >> V[i];
    for (int left = 0; left <= N; left++)
    {
        for (int right = 0; right <= N && left + right <= min(K, N); right++)
        {
            ll sum = 0, cnt = left + right;
            priority_queue<int, vector<int>, greater<int>> pq;
            for (int j = 0; j < left; j++)
            {
                sum += V[j];
                if (V[j] < 0)
                    pq.push(V[j]);
            }
            for (int j = 0; j < right; j++)
            {
                sum += V[N - 1 - j];
                if (V[N - 1 - j] < 0)
                    pq.push(V[N - 1 - j]);
            }
            while (cnt < K && !pq.empty())
            {
                cnt++, sum -= pq.top();
                pq.pop();
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
}

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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
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();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

ll getMinimumCost(int l, int r, vector<ll>& sum, vector<vector<ll>>& dp) { // [l, r)
    if (dp[l][r] != -1) return dp[l][r];

    assert(l+2<=r);
    vector<ll> candidates;
    REP(i,l+1,r) {
        candidates.emplace_back(getMinimumCost(l, i, sum, dp) + getMinimumCost(i, r, sum, dp) + sum[r] - sum[l]);
    }
    dp[l][r] = *min_element(candidates.begin(), candidates.end());
    return dp[l][r];
}

void solve(int N, vector<int>& a) {
    vector<vector<ll>> dp(N, vector<ll>(N+1, -1));
    REP(i,0,N) {
        dp[i][i+1] = 0;
    }

    vector<ll> sum(N+1);
    sum[0] = 0;
    REP(i,1,N+1) sum[i] = sum[i-1] + a[i-1];

	ll answer = getMinimumCost(0, N, sum, dp);
	stringstream ss;
	ss << answer;
	cout << ss.str() << '\n';

    return;
}

signed main() {
    int N;
    cin >> N;
    
    vector<int> A(N);
    REP(i,0,N) cin >> A[i];
    
    solve(N, A);
    
    return 0;
}



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


int main() {
    int t = 1;
    //  scanf("%d",&t);
    while (t--) {
        long long n,m;
        map<long long,int> dp;
        dp[0]++;
        scanf("%lld %lld",&n,&m);
        long long sum = 0,x;
        long long ans = 0;
        for(int i=0;i<n;i++){  
            scanf("%lld",&x);
            sum+=x;
            sum%=m;
            ans += (dp[sum]++);
        }
        printf("%lld\n", ans);
    }
    return 0;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
using ll = long long;

int main() {
    FAST;

    int n, i, k, sum = 0;;
    cin >> n >> k;

    vector<int> v(n);
    for (i = 0; i < n; ++i) cin >> v[i];
    sort(v.begin(), v.end());

    for (i = 0; i < k; ++i) sum += v[i];
    cout << sum;

    return 0;
}


Measured memory_bytes: 3656
fun main (args : Array<String>) {
	val (a, b) = readLine()!!.split(" ")
	val A : Int = a.toInt()
	val B : Int = b.toInt()
	var plus : Int = A + B
	var minus : Int = A - B
	var times : Int = A * B
	var list : MutableList<Int> = mutableListOf()
	list.add(plus)
	list.add(minus)
	list.add(times)
	list.sort()
	println("${list[2]}")
}

Measured memory_bytes: 36004
# -*- coding: utf-8 -*-

def solve():
    x, y = map(int, input().split())

    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]

    if x in a and y in a:
        return 'Yes'
    if x in b and y in b:
        return 'Yes'
    if x in c and y in c:
        return 'Yes'
    return 'No'

print(solve())

Measured memory_bytes: 3064
a, b = map(int, input().split())
import fractions
#import math
from functools import reduce
def lcm_base(x, y):
  return (x * y) // fractions.gcd(x, y)
  #return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

print(lcm_base(a, b))


Measured memory_bytes: 64108
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}



int a[210000],dp[210000];
int l,n;
int ans;

void f(){
  FOR(i,1,n+1){
    if(i%2){
      dp[i]=dp[i-1]+l-(a[i/2+1]-a[i/2])-2*(a[i]-a[i/2+1]);
    }else{
      dp[i]=dp[i-1]+l-2*(a[i]-a[i/2]);
    }

    ans=max(ans,dp[i]);
  }
}

main(){
  cin>>l>>n;
  FOR(i,1,n+1){
    cin>>a[i];
  }
  
  f();

  reverse(a+1,a+n+1);

  FOR(i,1,n+1){
    a[i]=l-a[i];
  }


  f();

  cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int k;
  string s;
  cin>>k;
  cin>>s;
  int n = s.size();
  if(n<=k)
    cout<<s;
  else
  {
    string a;
    for(int i=0;i<k+3;i++)
    {
        if(i<k)
            a+=s[i];
        else
            a+='.';
    }
    cout<<a;
  }
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define INF (1 << 31) - 1

int main() {
  string S;
  cin >> S;
  rep(i,S.size()){
    cout << "x";
  }
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = []
for i in range(n):
    a.append(list(map(int,input().split())))
a.sort(key = lambda a:a[0])
bought = 0
price = 0
for i in range(n):
    remain = m - bought
    if a[i][1] < remain:
        bought += a[i][1]
        price += a[i][0] * a[i][1]
    else:
        price += a[i][0]*remain
        print(price)
        exit()

Measured memory_bytes: 29024
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ちゃんとユニークな配列にする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  string s;
  cin >> s;
  int l = s.size();
  int cnt = 0;

  rep(i, l) {
    if(s[i] == '1') {
      cnt++;
    }
  }

  cout << cnt << endl;
}


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

using ll = long long;

ll f(ll a, ll k) {
  if (a < k) {
    return 0;
  }
  else if (a % k == 0) {
    return a / k;
  }
  else {
    ll res = a % k, keep = (a / k) + 1, keep2 = res / keep;
    if (keep2 == 0) return f(a - (a / k) - 1, k);
    else return f(a - keep2 * keep, k);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  ll nim = 0;
  for (int i = 0; i < n; i++) {
    ll a, k;
    cin >> a >> k;
    nim ^= f(a, k);
  }
  
  if (nim != 0) cout << "Takahashi\n";
  else cout << "Aoki\n";
}

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

using namespace std;

#define endl '\n'

int main(){

  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  long long a[n];
  long long ans[n];
  const long long mx = 1e18;

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

  sort(a,a+n);

  ans[0] = a[0];

  for(int i=1;i<n;i++){

     if(ans[i-1] && a[i] > mx/ans[i-1]){
      ans[n-1] = -1;
      break;
    }

    ans[i] = a[i]*ans[i-1];
  }

  if(ans[n-1] > mx){
    ans[n-1] = -1;
  }

  cout << ans[n-1] << endl;

  return 0;
}

Measured memory_bytes: 5208
n=int(input())
a=list(map(int,input().split()))
ans=999999999999999
temp=True
for i in range(2):
  count=0
  temp=0
  if i==0:
    t=True
  else:
    t=False
  for j in a:
    temp=temp+j
    if t==True and temp<1:
      count=count+1-temp
      temp=1
    elif t==False and temp>-1:
      count=count+1+temp
      temp=-1
    if t==True:
      t=False
    else:
      t=True
  ans=min(ans,count)
print(ans)

Measured memory_bytes: 14332
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;

signed main() 
{
    fastio;
    int n;
    cin>>n;
    vi a(n);
    f(i,n)cin>>a[i];
    int ans=1e18;
    for(int i=1;i<=100;i++)
    {
        int t=0;
        for(int j=0;j<n;j++)
        {
            t+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,t);
        
    }
    cout<<ans<<endl;
    
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int_Max 2147483647
#define ll_Max 9223372036854775807
#define REP(i,f,n) for(int i=f; i<(n); i++)

int main()
{
  int n, m;
  cin >> n >> m;
  pair<int, int> h[n], p[m];
  int cnt[n] = {0};
  REP(i,0,n){
    cin >> h[i].first >> h[i].second;
  }
  REP(i,0,m){
    cin >> p[i].first >> p[i].second;
  }

  REP(i,0,n){
    int kyori = int_Max, sai = 0;
    REP(j,0,m){
      int k = abs(h[i].first-p[j].first) + abs(h[i].second - p[j].second);
      if(k < kyori){
        kyori = k;
        sai = j;
      }
    }
    cnt[i] = sai + 1;
  }

  REP(i,0,n){
    cout << cnt[i] << endl;
  }

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

Measured memory_bytes: 3576
import java.nio.Buffer;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int sumA = 0;
        int sumB = 0;
        List<Integer> nums = new LinkedList<>();

        for(int i=0; i<n; i++){
            nums.add(sc.nextInt());
        }

        for(int i=1; i<n+1; i++){
            if(i%2 != 0){
                sumA += Collections.max(nums);
                nums.remove(nums.indexOf(Collections.max(nums)));
            }else{
                sumB += Collections.max(nums);
                nums.remove(nums.indexOf(Collections.max(nums)));
            }
        }

        System.out.println(sumA - sumB);


    }
}


Measured memory_bytes: 21844
N, K = [int(c) for c in input().split()]
V = [int(c) for c in input().split()]

max_value = 0
r_nega, r_posi = [],0
for n_take_r in range(min(K+1, N+1)):    
    if n_take_r >= 1:
        v_take = V[N-n_take_r]
        if v_take < 0: r_nega.append(v_take)
        else: r_posi += v_take
        
    l_nega, l_posi = [],0
    for n_take_l in range(min(K+1, N+1)-n_take_r):
        if n_take_l >= 1:
            v_take = V[n_take_l-1]
            if v_take < 0: l_nega.append(v_take)
            else: l_posi += v_take

        n_remove = K - n_take_r - n_take_l
        value = r_posi + l_posi + sum(sorted(r_nega+l_nega)[n_remove:])
        max_value = max(max_value, value)

print(max_value)
        

        


Measured memory_bytes: 3064
#include<iostream>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(x,y) (abs((x.first)-(y.first))+abs((x.second)-(y.second)))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  // ここでストリームに obj を書き込みます。
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}


int main(){
  int n,m; cin >>n >>m;
  vector<pair<int,li>>st(n),ch(m);
  rep(i,n){
    int a,b; cin >>a >>b; st[i]={a,b};
  }
  rep(i,m){
    int a,b; cin >>a >>b; ch[i]={a,b};
  }
  rep(i,n){
    li d=dist(st[i],ch[0]),k=1;
    repa(j,1,m){
      if(df) print(d,dist(st[i],ch[j]));
      if(chmin(d,dist(st[i],ch[j]))){
        k=j+1;
        if(df) print("c");
      }
      if(df)print("->",d);
    }
    print(k);
  }
}




Measured memory_bytes: 256
using AtCoderBeginnerContest156.Questions;
using AtCoderBeginnerContest156.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest156.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nk = inputStream.ReadIntArray();
            var n = nk[0];
            var k = nk[1];

            var digit = 0;
            while (n > 0)
            {
                digit++;
                n /= k;
            }

            yield return digit;
        }
    }
}


namespace AtCoderBeginnerContest156
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest156.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest156.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
#include <inttypes.h>
int main(){
	long long N,M,x;
    long long ans=0;
	std::cin >>N>>x;
    std::vector<int> a(N);
    for(int i=0;i<N;i++){
        std::cin >> a[i];
    }
    if(a[0]>x){
        ans=a[0]-x;
        a[0]=x;
    }
    for(int i=1;i<N;i++){
        
        if(a[i-1]+a[i]>x){
            int res=-x+a[i-1]+a[i];
            ans+=res;
            a[i]-=res;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void) {
	long long a, b, x;
	cin >> a >> b >> x;
	if (a == 0)
		cout << b / x + 1 << "\n";
	else
		cout << (b / x) - ((a - 1) / x) << "\n";
	return 0;
}

Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    H, W = read_ints()
    A = []
    for _ in range(H):
        A.append(read_ints())
    answer = []
    last = None
    for i in range(H):
        for j in range(W):
            if i%2 == 1:
                j = W-j-1
            if last is not None and A[last[0]][last[1]]%2 == 1:
                A[i][j] += 1
                answer.append((last[0]+1, last[1]+1, i+1, j+1))
            last = (i, j)
    print(len(answer))
    for a in answer:
        print(*a)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 100040
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin>>s;
	sort(all(s));
	if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


int main() {
  int a, b;
  cin >> a >> b;
  cout << max(0, a - 2*b) << endl;
}


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

int main() {
  int A=0,B=0;
  cin >> A >> B;

  // ここにプログラムを追記
  int Kekka=0,i=0;
  for (int i=A; i<=B; i++) {
    if (((i/10000)==(i-(i/10)*10)) && ((i-(i/10000)*10000)/1000==(i-(i/100)*100)/10)) {
      Kekka++;
    }
  }
  cout << Kekka << endl;
}


Measured memory_bytes: 256
h = [int(x) for x in input().split(' ')]
n = h[0]
k = h[1]

result = 0

l = {}
for i in range(n):
  l[i+1] = False

for i in range(k):
  num = input()
  has = [int(x) for x in input().split(' ')]
  for mem in has:
    l[mem] = True

for mem in l.values():
  if not mem:
    result += 1

print(result)

Measured memory_bytes: 9200
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  long long lack = 0;
  int num = 0;
  vector<int> a, b, surplus;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    b.push_back(tmp);
  }

  for (int i = 0; i < n; i++) {
    if (a[i] > b[i]) {
      //余剰
      surplus.push_back(a[i] - b[i]);
    } else if (a[i] < b[i]) {
      //不足
      num++;
      lack += b[i] - a[i];
    }
  }
  if (num == 0) {
    cout << "0" << endl;
    return 0;
  }
  sort(surplus.begin(), surplus.end());
  reverse(surplus.begin(), surplus.end());
  for (int i = 0; i < surplus.size(); i++) {
    if (lack <= surplus[i]) {
      cout << num + 1 << endl;
      return 0;
    } else {
      num++;
      lack -= surplus[i];
    }
  }
  cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    int cnt = 0;
    string abc = "ABC";

    REP(i,n) {
        if (s[i] == abc[cnt]) {
            if (cnt == 2) {
                ans++;
                cnt = 0;
            } else cnt++;
        } else {
            cnt = 0;
            if (s[i] == abc[0]) cnt++;
        }
    }

    cout << ans << '\n';

    return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define LEFT(i) (2*(i))
#define RIGHT(i) (2*(i)+1)
#define PARENT(i) ((i)/2)

//ヒープ木の構成要素型の定義
typedef struct{
    double priority; //ここの値で降順にする！！
    double value;
}heapdata;

//ヒープ木型の定義
typedef struct{
    int max_size;   //ヒープ二分木(配列A)の中に格納できる最大要素数
    int heap_size;  //ヒープ二分木(配列A)の中に現在入っている要素の数
    heapdata* A;    //要素を格納するための配列(ポインタ)
}* heap;

//ヒープH内の配列のA[i]とA[j]の値を入れ替える関数
void heap_swap(heap H,int i,int j){
    heapdata tmp;
    
    tmp=H->A[i];
    H->A[i]=H->A[j];
    H->A[j]=tmp;
    
    return;
}

//HEAPIFY O(nlogn)
//A[i]を根とする部分木がヒープになるように整序する関数
void heapify(heap H, int i){
    int l,r,largest,size;
    heapdata* A;
    
    l=LEFT(i); //iの左の子の添字
    r=RIGHT(i); //iの右の子の添字
    size=H->heap_size; //今のヒープHのサイズ
    A=H->A; //ヒープ二分木に格納されている要素の配列
    
    //以下largestを決めるコード
    if(l>size&&r>size){
        largest=i;
    }
    else if(l<=size&&r>size){
        if(A[l].priority>A[i].priority){
            largest=l;
        }
        else{
            largest=i;
        }
    }
    else{
        if(A[r].priority>A[l].priority){
            largest=r;
        }
        else{
            largest=l;
        }
        if(A[i].priority>A[largest].priority){
            largest=i;
        }
    }
    
    //largestが決まったら要素を入れ替えする
    if(largest!=i){
        heap_swap(H,i,largest);
        heapify(H,largest);
    }
    
    return;
}

//BUILD_HEAP O(n)
//要素n個の配列A[1]~A[n]、max_sizeをもつヒープ木Hのメモリを確保し出力する関数
heap heap_build(int n, heapdata* A, int max_size){
    int i;
    heap H;
    NEW(H,1);
    
    H->max_size=max_size;
    H->heap_size=n;
    H->A=A;
    
    for(i=n/2;i>=1;i--){
        heapify(H,i);
    }
    
    return H;
}

//EXTRACT_MAX O(logn)
//ヒープ木の中の最大要素を削除し出力、その最大要素を除いたヒープ木を再構成する関数
heapdata extract_max(heap H){
    int n=H->heap_size;
    
    heap_swap(H,1,n);
    H->heap_size=n-1;
    heapify(H,1);
    
    return H->A[n];
}

//INSERT O(logn)
//data xをヒープHに挿入する関数
void heap_insert(heap H,heapdata x){
    int n=H->heap_size;
    
    if(n==H->max_size){
        printf("ERROR　cannot insert anymore\n");
        return;
    }
    else{
        H->A[n+1]=x;
        H->heap_size=n+1;
        
        int i=n+1;
        while(PARENT(i)>=1&&H->A[i].priority>H->A[PARENT(i)].priority){
            heap_swap(H,i,PARENT(i));
            i=PARENT(i);
        }
        return;
    }
}

int main(void){
    int N;
    scanf("%d",&N);

    //A[1]~A[N]に格納
    heapdata* A;
    NEW(A,N+1)
    for(int i=1;i<=N;i++){
        scanf("%lf",&A[i].priority);
    }

    double M=0;

    heap T =heap_build(N,A,N);
    while(T->heap_size>0){;
        M+=1/extract_max(T).priority;
    }

    double ans=1/M;
    printf("%lf\n",ans);

    return 0;
}

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

int main(){
  int n;
  std::cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  int mini = 1, pos = 0;
  long long int ans = 0;
  for (int i = 0; i < n; i++) {

    if(a[i] == mini){
      
    }else if(a[i]%mini == 0){
      ans += (a[i]/mini) - 1;
      a[i] = 1;
    }else{
      ans += a[i]/mini;
      a[i] = 1;
    }
    mini = max(mini, a[i] + 1);
    // std::cout << "mini:" << mini << " pos:" << i << " ans";
    // std::cout << ans << std::endl;
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 640
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    ll n;cin>>n;

    vl l(n), r(n);
    rep(i, n){
        cin>>l[i]>>r[i];
        // dump(l[i], r[i]);
    }
    sort(all(l));
    sort(all(r));
    dump(l);
    dump(r);

    if(n%2==1){
        ll m = (n+1)/2;
        m--;
        cout << r[m] - l[m] + 1 << endl;
    }
    else{
        ll left = (l[n/2-1] + l[n/2]);
        ll right = (r[n/2-1] + r[n/2]);
        cout << right - left + 1 << endl;
    }

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 6376
#include<stdio.h>
int prime(int x){
    int i;
    for(int i=2;i*i<=x;++i)
	if(x%i==0) return 0;
    return 1;
}
int main(){
    int n,x,i,cnt=0;
    scanf("%d",&n);
    for(i=1;i<=n;++i){
	scanf("%d",&x);
	cnt+=prime(x);
    }
    printf("%d\n",cnt);
    return 0;
}


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

int n, k;
long long arr[200000];

int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> arr[i];
	sort(arr, arr + n, greater<long long>());
	long long cnt = 0;
	for(int i = k; i < n; i++) cnt += arr[i];
	cout << cnt << "\n"; 
	return 0;
}


Measured memory_bytes: 1792
def next(a,b,c,k):
	
	s = 0
	if k >= a:
		s += a
		k -= a
	else:
		print(k)
		return
	if k >= b:
		k -= b
	else:
		print(a)
		return

	print(s-k)
	return


    
#m = int(input())

#for t in range(m):
#	n = int(input())
a,b,c,k = map(int,input().split())
#s = input()
#t = input()
next(a,b,c,k)
'''arr = list(map(int,input().split()))
qarr = []
for i in range(b):
	qarr.append(int(input()))

#k = input()
#n = int(input())
Sol(a,b,arr,qarr)'''
#for i in range(n):
#	next(int(input()))



Measured memory_bytes: 61572
n,k,*a=`dd`.split.map &:to_i
a=(b=[0])+a
1.upto(a.size-1){|i|b[i]=b[i-1]+[0,a[i]].max;a[i]+=a[i-1]}
p (k...a.size).map{|i|b[-1]-b[i]+b[i-k]+[a[i]-a[i-k],0].max}.max

Measured memory_bytes: 13680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
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; }
int main()
{
    int K,S;
    cin >> K>>S;


    int cnt=0;
    REP(i,K+1){
        REP(j,K+1){
            if((i+j)>S) continue;
            if(S<=(i+j+K)){
                //cout << i <<" "<< j << endl;
                cnt++;
            }
        }
    }


    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static long gcd(long a, long b) {
        if (a < b) {
            return gcd(b,a);
        }
        if (a % b == 0) {
            return b;
        }
        return gcd(b, a % b);
    }
    private static long lcm(long a, long b) {
        return (a / gcd(a, b)) * b;
    }
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        long res = 1;
        long n = in.nextLong();
        for(int i=0;i<n;i++) {
            long t = in.nextLong();
            res = lcm(res, t);
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 23764
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string s;
    cin >> s;

    int l = 0, r = s.size() - 1;
    int a = 0, b = s.size();
    while(l < r) {
        if (s[l] != s[l+1]) a = l+1;
        if (s[r - 1] != s[r]) b = r;
        ++l; --r;
    }

    print(min<int>(s.size() - a, b));
    
}


Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>
using namespace std;
  
int main(){
	int a, b, c;
	cin >> a >> b >> c;
    int d = b + c;
    if(d > a){
	int f = d - a;
    cout << f;
    }
    else{
    cout << 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Dim 100008
using namespace std;
ifstream f("D.in");
typedef long long ll;

unordered_map < ll ,int > H;

int main()
{
    ll N;
    cin>>N;
    ll x,suma=0;
    for(int i=1;i<=N;i++)
    {
        cin>>x;
        H[x]++;
        suma+=x;
    }
    ll Q;
    cin>>Q;
    for(int i=1;i<=Q;i++)
    {
        ll B,C;
        cin>>B>>C;
        suma=suma-H[B]*B;
        suma=suma+H[B]*C;
        H[C]+=H[B];
        H[B]=0;
        cout<<suma<<'\n';
    }

    return 0;
}


Measured memory_bytes: 7128
"""
problem statment url: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A
"""

from __future__ import division
from sys import stdin, maxint

def solve(n, m, ds):
    dp = [maxint] * (n + 1)
    dp[0] = 0
    for i in range(m):
        for j in range(ds[i], n + 1):
            dp[j] = min(dp[j], dp[j - ds[i]] + 1)

    return dp[n]

if __name__ == '__main__':
    n, m = map(int, stdin.readline().strip().split())
    ds = map(int, stdin.readline().strip().split())
    print(solve(n, m, ds))

Measured memory_bytes: 9384
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll a[n];
	for(ll i=0; i<n;i++)
		cin >> a[i];
	sort(a, a+n);
	cout << a[n-1]-a[0];
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
 os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os << "(" << P.first << "," << P.second << ")";}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif


#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector< pii >


// const int mod=1e9+7;
// inline int mul(int a,int b){return (a*1ll*b)%mod;}
// inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
// inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
// inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
// inline int inv(int a){return power(a,mod-2);}
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;} 

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int N; cin>>N;
	int ans = 0;
	while(N>0){
		ans += N%10;
		N/=10;
	}
	if(ans==1)ans = 10;
	cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;

typedef long long ll;
int main(){
    string s,t;
    cin >> s >> t;
    int count;
    REP(i,3)s[i]==t[i] ? count ++ : count;
    cout << count << endl;
}

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

ll f(ll a, ll b) {
  if (b == 0) return 0;
  if (a % b == 0) return 2 * b * ((a - 1) / b) + b;
  return f(b, a % b) + 2 * b * (a / b);
}

ll N, X;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> X;
  cout << N + f(N - X, X) << endl;

  return 0;
}

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

using namespace std;

#define bug(x) cerr << #x << " = " << x << '\n'
#define ll     long long
#define maxn   200005

int n, k;
int a[maxn];

bool f (int x) {
        ll cnt = 0;
        for(int i = 1; i <= n; ++ i) {
            cnt += (ll) (a[i] - 1LL) / x;
            if(cnt > k) return false;
        }
        return cnt <= k;
}

int main() {
        //freopen(".inp","r",stdin);

        cin >> n >> k;

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

        int lo = 0, hi = (int) 1e9 + 7;

        while(hi - lo > 1) {
            int mid = (hi + lo) / 2;
            if(f(mid)) hi = mid;
            else lo = mid;
        }
        cout << hi;
}



Measured memory_bytes: 4344
#include <stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

int main(void)
{
	int a,b,c,d,i,j,k,x=0,e,f;
	if(a<b){
		a=e;
		a=b;
		b=e;
	}
	if(a<c){
		a=e;
		a=c;
		c=e;
	}
	if(b<c){
		b=e;
		b=c;
		c=e;
    }
	scanf("%d %d %d %d",&a,&b,&c,&d);
	for(i=0;i<d+1;i++){
		for(j=0;j<d-a*i+1;j++){
			if(a*i+b*j>d) break;
			else if((d-a*i-b*j)%c==0){
				x++;
			}
		}
	}
	printf("%d",x);
	return 0;
}

Measured memory_bytes: 128
def m():
    n = int(input())
    a = list(map(int, input().split()))
    total = abs(a[0]) + abs(a[n-1])
    for i in range(1, n):
        total += abs(a[i] - a[i-1])
    for j in range(n):
        if j == 0:
            print(total - abs(a[j]) - abs(a[j]-a[j+1]) + abs(a[j+1]))
            continue
        if j == n-1:
            print(total - abs(a[j-1]-a[j]) - abs(a[j]) + abs(a[j-1]))
            continue
        print(total - abs(a[j-1]-a[j]) - abs(a[j]-a[j+1]) + abs(a[j+1]-a[j-1]))


m()


Measured memory_bytes: 14164
#include <bits/stdc++.h>
#define pb push_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pi pair<int, int>
#define int long long
using namespace std;


signed main()
{
    /*
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);*/
    int a, b, w, v, t;
    cin >> a >> v >> b >> w >> t;
    if (a == b) {
        cout << "YES";
        return 0;
    }
    if (v < w) {
        cout << "NO";
        return 0;
    }
    int d = abs(a - b), s = t * (v - w);
    if (s >= d) {
        cout << "YES";
    } else cout << "NO";
    return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define pqll priority_queue<ll>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) ll a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define ub upper_bound
#define lb lower_bound
#define mapp map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define qll queue<ll>
#define sll set<ll>
#define inf LLONG_MAX
#define N 10000001

vll di(N);

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

	for(ll i=0;i<N;i++)
		di[i]=0;
	ll n;
	cin>>n;
	for(ll i=1;i<=n;++i)
		for(ll j=i;j<=n;j+=i)
			di[j]++;
	ll ans=0;
	for(ll i=1;i<=n;i++)
		ans+=i*di[i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 81216
n,m = map(int, input().split())
reach = [0]*(n+1)
l = [[] for i in range(n+1)]
for i in range(m):
  a,b = map(int, input().split())
  l[a].append(b)
  l[b].append(a)
  
def dfs(s, parent):
  reach[s] = 1
  for i in l[s]:
    if i == parent: continue
    if reach[i] == 0:
      dfs(i, s)
    else:
      reach[i] += 1

loop = [0]*(n+1)
for i in range(1, n+1):
  reach = [0]*(n+1)
  dfs(i, 0)
  if reach[i] != 1:
    loop[i] = 1
ans = 0
for i in range(1, n+1):
  for j in l[i]:
    if loop[i] == 1 and loop[j] == 1:
      ans += 1
print(m - ans//2)

Measured memory_bytes: 9148
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cassert>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll q,h,s,d;
    cin >>q >> h >> s >> d;
    ll n;
    cin >> n;
    ll ans = 1LL<<61;
    ll k = min(s,min(h*2,q*4));
    ans = min(k*n,n/2*d+k*(n%2));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main() {
  int n, a[32] = {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};
  scanf("%d", &n);
  printf("%d\n", a[n - 1]);
}

Measured memory_bytes: 128