akhauriyash/Code-Regression huggingface dataset:
//  string t = "keyence";//で文字列入力ができる
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int kan_hyaku(int n){
  int kurai = 0;
  for(int i=0;i<3;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ju(int n){
  int kurai = 0;
  for(int i=0;i<2;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ichi(int n){
  int kurai = 0;
  for(int i=0;i<1;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int main() {
  int n;
  cin >> n;
  vector<int>b(100000000);
  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
      for(int k=1;k<=100;k++){
        b.at(i*i+j*j+k*k+i*j+j*k+k*i)++;
      }
    }
  }
  
  for(int i=1;i<=n;i++){
    cout << b.at(i) << endl;
  }
}

Measured memory_bytes: 393820
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)

#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, N;

void enqueue(P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int main()
{   
    int elaps = 0, c;
    int n, q;
    cin >> n >> q;
    P u;
    for (int i = 1; i <= n; i++) {
        cin >> Q[i].name >> Q[i].t;
    }
    head = 1;
    tail = n + 1;

    while (head != tail) {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0) {
            enqueue(u);
        } else {
            cout << u.name << " " <<  elaps << endl;
        }
    }
    return 0;
}



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

using namespace std;

int main(void) {
    string s;
    cin >> s;
    int count;
    if (s == "RRR") {
        count = 3;
    } else if (s == "RRS" || s == "SRR") {
        count = 2;
    } else if (s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR") {
        count = 1;
    } else {
        count = 0;
    }
    cout << count << endl;



    return 0;
}

Measured memory_bytes: 3616
h,w=map(int,input().split())
s=[input() for _ in range(h)]
for i in range(h):
    l=""
    for j in range(w):
        if s[i][j]=="#":
            l+="#"
        else:
            l+=str(sum([t[max(0,j-1):min(w,j+2)].count("#") for t in s[max(0,i-1):min(h,i+2)]]))
    print(l)

Measured memory_bytes: 40944
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int i = 1;
        int n;
        while ((n = sc.nextInt()) != 0) {
            System.out.println("Case " + i + ": " + n);
            i++;
        }
	}
}

Measured memory_bytes: 31324
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var x = int.Parse(str);
            if (x == 7 || x == 5 || x == 3)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}


Measured memory_bytes: 11092
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(h1, m1, h2, m2, k);
    cout << max(h2*60+m2-(h1*60+m1)-k, 0LL) << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3668
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;

int main(){
    int n;
    cin >> n;
    vector<ll>a(n),b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    ll ans = 0;
    vector<pair<ll,int>>vec;
    rep(i,n){
        vec.emplace_back(a[i]+b[i],i);
    }
    sort(vec.rbegin(),vec.rend());
    rep(i,n){
        if(i%2==0){
            ans += a[vec[i].second];
        }else{
            ans -= b[vec[i].second];
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  for (int x = 1; x <= 1000; x++) {
    if ((int)floor(x * 0.08) == a && (int)floor(x * 0.1) == b) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
# h = input().replace(" ", "")
# print(h)
count = 0
while 1:
    if sum(h) == 0:
        break
    else:
        # print(h)
        # h = h.strip("0")
        if 0 in h:
            while 1:
                num = h.pop(0)
                if num != 0:
                    h.insert(0, num)
                    if 0 in h:
                        i = h.index(0)
                        h = list(map(lambda x: x - 1, h[:i]))+h[i:]
                    else:
                        h = list(map(lambda x: x-1, h))
                    break
            # i = h.index(!0)
            # h = str(int(h)-int(str("1")*i+"0"*(len(h)-i)))
            count += 1
        else:
            h = list(map(lambda x: x-1, h))
            # h = str(int(h) - int(str("1" * len(h))))
            count += 1

print(count)


Measured memory_bytes: 42352
N = gets.to_i
bs = gets.strip.split(/ /).collect{|x| x.to_i}

process = [:dummy] + [nil] * N

def put(process, n)
	j = 1
	i = 1
	while j <= N
		if process[j]
		else
			if i == n
				process[j] = n
				return j
			end
			i += 1
		end
		j += 1
	end
	nil
end

N.times{|i|
	b = bs.pop
	
	unless put(process, b)
		puts "-1"
		exit
	end
}

(1..N).each{|i|
	puts process[i]
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n,m;
  while(cin>>n>>m,n||m){
    vector<vector<Int> > G(n);
    for(Int i=0;i<m;i++){
      Int x,y;
      cin>>x>>y;
      x--;y--;
      G[x].emplace_back(y);
      G[y].emplace_back(x);
    }
    vector<Int> dp(n,-1);
    queue<Int> q;
    dp[0]=0;
    q.emplace(0);

    Int flg=1;
    while(!q.empty()){
      Int v=q.front();q.pop();
      for(Int u:G[v]){
	flg&=dp[u]!=dp[v];
	if(~dp[u]) continue;
	dp[u]=dp[v]^1;
	q.emplace(u);
      }
    }

    vector<Int> ans;
    if(flg){
      Int x=0;
      for(Int i=0;i<n;i++) x+=dp[i];
      Int y=n-x;
      if(x%2==0) ans.emplace_back(x/2);
      if(y%2==0) ans.emplace_back(y/2);
    }
    
    sort(ans.begin(),ans.end());
    ans.erase(unique(ans.begin(),ans.end()),ans.end());
    cout<<ans.size()<<endl;
    for(Int x:ans) cout<<x<<endl;
  }
  return 0;
}



Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; 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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N;
int A[1000], B[1000];
int K;
vector<int> divs;
int sum;
int csum[1000];

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

  for (int i = 1; i * i <= sum; ++i) {
    if (sum % i == 0) {
      divs.push_back(i);
      if (sum / i != i) {
        divs.push_back(sum / i);
      }
    }
  }
  sort(divs.begin(), divs.end(), greater<int>());

  for (auto d : divs) {
    rep(i, 0, N) { B[i] = A[i] % d; }
    sort(B, B + N);
    rep(i, 0, N) { csum[i + 1] = csum[i] + B[i]; }
    repe(i, 0, N) {
      ll dec = csum[i];
      ll inc = d * 1LL * (N - i) - (csum[N] - csum[i]);
      if (max(dec, inc) <= K && abs(dec - inc) % d == 0) {
        cout << d << endl;
        return 0;
      }
    }
  }
}


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

int gcd(int x, int y) // x > y
{
    if (y == 0) {
        return x;
    }
    return gcd(y, x % y);
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> left(n);
    left[0] = a[0];
    for (int i = 1; i < n; i++) {
        left[i] = gcd(left[i - 1], a[i]);
    }
    vector<int> right(n);
    right[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        right[i] = gcd(right[i + 1], a[i]);
    }
    int ans = 1;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            ans = max(ans, right[1]);
        } else if (i == n - 1) {
            ans = max(ans, left[n - 2]);
        } else {
            ans = max(ans, gcd(left[i - 1], right[i + 1]));
        }
    }
    cout << ans << endl;
    return 0;
}

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


int gcd(int a, int b);
int gcd(int a, int b, int c);


int main()
{
    unsigned int K, result;
    cin >> K;
    int sum = 0;
    for (int i = 1 ; i <= K ; i++)
    {
        for (int k = 1 ; k <= K ; k++)
        {
            for (int l = 1 ; l <= K ; l++)
            {
                result = gcd(i, k, l);
                sum += result;
            }
        }
    }
    cout << sum << endl;
    return 0;
}


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

// min of all is a
int gcd(int a, int b, int c)
{
    return gcd(a, gcd(b,c));
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int mod=1000000007,INF=1099999999999999999;


queue<long long int>que[200005],task;
long long int q[200005],x[200005];
long long int m,Q,k,n,a[200005],b[200005],res[200005]={},sum,po[200005]={};
long double d[3000],dres=0;
string str;




int main() {
	cout << fixed << setprecision(10);
    cin>>n>>Q;
    for(int i=0;i<n-1;i++){
        cin>>a[i]>>b[i];
        que[a[i]].push(b[i]);
    }
    for(int i=0;i<Q;i++){
        cin>>q[i]>>x[i];
        po[q[i]]+=x[i];
    }
    res[1]=po[1];
    task.push(1);
    while(!task.empty()){
        long long int now=task.front();
        task.pop();
        while(!que[now].empty()){
            res[que[now].front()]=res[now]+po[que[now].front()];
            task.push(que[now].front());
            que[now].pop();
            
        }
    }
    for(int i=1;i<=n;i++){
        cout<<res[i]<<" ";
    }
} 


Measured memory_bytes: 146816
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  int ans=0;
  rep(i,N/4+1) if((N-i*4)%7==0) ans++;
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



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

constexpr int INF = 1LL << 60;

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

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

signed main() {

    int n, m;
    while(true){
        cin >> n >> m;
        if(n == 0 && m == 0){
            break;
        }
        
        vector<int> c(m);
        rep(i, m){
            cin >> c[i];
        }
        vector<int> x(n);
        rep(i, n){
            cin >> x[i];
        }

        vector<vector<int>> dp(n+1, vector<int>(256, INF));
        dp[0][128] = 0;
        for(int i=0; i<n; i++){
            for(int j=0; j<=255; j++){
                if(dp[i][j] == INF){
                    continue;
                }
                for(int k=0; k<m; k++){
                    if(c[k] < 0){
                        chmin(dp[i+1][max(0LL,c[k]+j)], dp[i][j]+(max(0LL,c[k]+j)-x[i])*(max(0LL,c[k]+j)-x[i]));
                    }
                    else{
                        chmin(dp[i+1][min(255LL,c[k]+j)], dp[i][j]+(min(255LL,c[k]+j)-x[i])*(min(255LL,c[k]+j)-x[i]));
                    }
                }
            }
        }
        
        int ans = INF;
        for(int i=0; i<=255; i++){
            if(dp[n][i] == INF) continue;
            chmin(ans,dp[n][i]);
        }
        cout << ans << endl;
    }
    
    
    return 0;
}




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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  1 <= A, B, C, D <= 10;
  
  int L = A + B;
  int R = C + D;
  
  if(R == L){
    cout << "Balanced" << endl;
  }
  else if (R<L){
    cout << "Left" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}


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

#define int long long 
#define double long double

typedef pair<int,int> pi;

typedef vector<int> vi;
typedef vector<pi> vpi;

#define f first
#define s second
#define mp make_pair
#define pb push_back

#define gcd __gcd

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}
set<char> a,b;

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int n;
  string s;cin >> s;
  n = s.size();
  while(n--){
  	char o = s[n];
  	if(o == 'N')a.insert(o);
  	if(o == 'S')a.insert(o);
  	if(o == 'W')b.insert(o);
  	if(o == 'E')b.insert(o);
  }
  if(a.size() == 1 || b.size() == 1)cout << "No";
  else cout << "Yes";
  return 0;
}

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

typedef unsigned uint;

unsigned count(std::vector<uint> s, std::vector<uint> t){
  uint n = 0;
  for(uint i = 0; i < t.size(); i++){
    for(uint j = 0; j < s.size(); j++){
      if(s[j] == t[i]){n++;break;}
    }
  }
  return n;
}

int main(){
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::vector<uint> s,t;

  {
    uint n,buf;
    std::cin >> n;
    for(; n; n--){
      std::cin >> buf;
      s.push_back(buf);
    }
  }

  {
    uint q,buf;
    std::cin >> q;
    for(; q; q--){
      std::cin >> buf;
      t.push_back(buf);
    }
  }

  std::cout << count(s,t) << '\n';
}

Measured memory_bytes: 1324
'use strict'

function main(input) {
  input = Number(input)
  const divider = 1000000007

  let power = 1
  for (let i=1; i<=input; i++) {
    power = (power * i) % divider
  }

  console.log(power)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,m,sum=0;
  cin>>n>>m;
  vector<int> v(m);
  for(long i=0;i<m;i++)
  {
      cin>>v[i];
  }
  for(long i=0;i<m;i++)
  {
   sum+=v[i];   
  }
  if(n-sum>=0)
  {
      cout<<n-sum<<"\n";
  }
  else
  {
      cout<<"-1"<<"\n";
  }
  return 0;
}

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

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

#define MOD 1000000007LL

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

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

int main(void) {
    string N;
    cin >> N;
    rep(i, 2) {
        if(N[i] == N[i + 1] && N[i + 1] == N[i + 2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main(){
  int n;
    cin >> n;
  vector<int> a(n);
  int sum=0;
    for(int i=0; i<n; i++){
      cin >> a.at(i);
      sum += a[i];
    }
    sort(a.begin(), a.end());

    if(sum%10 == 0){
      for(int i=0; i<n; i++){
        if(a[i]%10!=0){
          sum -= a[i];
          break;
        }
      }

    }
    if(sum%10==0) sum=0;
    cout << sum << endl;
}


Measured memory_bytes: 256
/*
题意：给定整数 n， 请问 n 以内有多少个素数？
思路：如果对许多整数进行素性测试，则采用 埃氏筛法 （枚举 n 以内的素数，辗转相除）
		埃氏筛法：辗转相除：
			首先，将 2 到 n 范围内的所有整数写下来。其中最小的数字 2 是素数。将表中所有 2 的倍数都划去。
			表中剩余的最小数字是 3，它不能被更小的数整除，所以是素数。再将表中所有 3 的倍数都划去。
			以此类推，如果表中剩余的最小数字是 m 时，m就是素数。然后将表中所有 m 的倍数都划去。 
			像这样反复操作，就能依次枚举 n 以内的素数。 
*/

#include <iostream>
#include <stdio.h>
using namespace std;
#define MAX_N  999999

int prime[MAX_N];		// 第 i 个素数 
bool is_prime[MAX_N];	// is_prime[i] 为 true 表示 i 为素数 

// 返回 n 以内素数的个数 
int sieve( int n )
{
	int p = 0;
	for( int i = 0; i <= n; i++ )
		is_prime[i] = true;
	
	is_prime[0] = is_prime[1] = false;
	
	for( int i = 2; i <= n; i++ )
	{
		if( is_prime[i] )
		{
			prime[p++] = i;
			for( int j = 2 * i; j <= n; j += i )
				is_prime[j] = false;				
		}	
	}
	return p;
} 

int main()
{	
	int s;
//	while (cin  >>  s)
	while (scanf("%d", &s) != EOF) 
	{
		cout << sieve(s) << endl;
	}	
	return 0;
}



Measured memory_bytes: 4332
# include <bits/stdc++.h>
# define endl "\n"
# define int long long
using namespace std;

void solve() {

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

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif
	// int t;
	// cin >> t;
	// while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n,m;
    cin >> n >> m;
    int sum=0;
    REP(i,m){
        int a;
        cin >> a;
        sum+=a;
    }
    if(sum>n) cout << -1;
    else cout << n-sum;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
int main(void){
	double r;
	scanf("%lf",&r);
	double s,l,pi;
	 pi = 4 * atan(1.0);  
	 s = r*r*pi;
	 l = 2*pi*r;
	printf("%lf %lf\n",s,l);
	return 0;
}


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

using namespace std;

int main(){

	int n;
	cin >> n;
	map<string,int> m;
	while(n--){
		string s;
		cin >> s;
		m[s]++;

	}
	cout <<"AC x " << m["AC"] << endl;
	cout <<"WA x "<< m["WA"] << endl;
	cout <<"TLE x "<< m["TLE"] << endl;
	cout <<"RE x " <<  m["RE"] << endl;

	return 0;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <string>
using namespace std;
int main() {
	int X;
	scanf("%d", &X);
	int u = 0;
	int x;
	x= X / 500;
	int xx;
	xx = X % 500 / 5;
	u = x * 1000 + xx * 5;
	printf("%d\n", u);
	
}

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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a_val = sqrt(n);
  FOR(now, 1, n+1){
    int ans = 0;
  FOR(i, 1, a_val+1){
    int tmp = n - i*i;
    int b_val = sqrt(tmp);
    FOR(j, i, b_val+1){
      int tmp2 = tmp - j*j;
      int c_val = sqrt(tmp2);
      FOR(k, j, c_val+1){
        if (i*i + j*j + k*k + i*j + j*k + k*i == now){
          if (i==j and j==k) ans++;
          if (i==j and j !=k) ans += 3;
          if (i!=j and j==k) ans+=3;
          if (i!=j and j!=k) ans += 6;
        }
      }
    }
  }
  cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

const int MAXN = 1000000;
Int fact[MAXN], inv[MAXN];

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

void init_fact() {
    fact[0] = 1;
    for(int i=1; i<MAXN; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    inv[MAXN - 1] = mod_pow(fact[MAXN - 1], MOD-2);
    for(int i=MAXN - 2; i>=0; i--) {
        inv[i] = (inv[i+1] * (i+1)) % MOD;
    }
}

Int comb(int n, int r) {
    if(r < 0 || n < r) return 0;
    return fact[n] * inv[n-r] % MOD * inv[r] % MOD;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

vector<Int> Divisor(Int n) {
    vector<Int> ret;
    for(Int i=1; i*i<=n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n / i);
        }
    }
    return ret;
}

int main(){
    cin.tie(0);

    Int N; cin >> N;
    vector<Int> div = Divisor(N);
    vector<int> flag(div.size(), 1);
    sort(div.begin(), div.end());

    int ans = 0;
    for (int i = div.size()-2; i >= 0; i--){
        if (flag[i]){ 
            ans++;
            for (int j = i; j >= 0; j--){
                if (div[i] % div[j] == 0) flag[j] = 0;
            }
        }
    } 
    cout << ans << " " << div.size()-1 << endl;


    return 0;

}




Measured memory_bytes: 3152
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


#define MOD 1000000007

long long dp[51][51][2501];


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


	int n, k;
	cin >> n >> k;

	if (k & 1) {
		cout << 0 << endl;
		return 0;
	}
	k /= 2;

	dp[0][0][0] = 1;

	rep(i, n) rep(j, n + 1) rep(s, k + 1) if(dp[i][j][s]){
		if (0 < j) {
			int x = j - 1;
			(dp[i + 1][x][s + x] += dp[i][j][s] * j % MOD * j) %= MOD;
		}
		{
			int x = j;
			(dp[i + 1][x][s + x] += dp[i][j][s] * 2 * j) %= MOD;
		}
		{
			int x = j;
			(dp[i + 1][x][s + x] += dp[i][j][s]) %= MOD;
		}
		{
			int x = j + 1;
			(dp[i + 1][x][s + x] += dp[i][j][s]) %= MOD;
		}
	}

	cout << dp[n][0][k] << endl;

	return 0;
}

Measured memory_bytes: 48128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n;
	cin>>n;
	vector<pair<ll,ll>>sz;
	for(int i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		sz.push_back({y,x});
		
	}
	sort(sz.begin(),sz.end());
	ll time=0;
	bool can=true;
	for(int i=0;i<sz.size();i++)
	{
		time+=sz[i].second;
		if(time>sz[i].first)
		{
			can=false;
			break;
		}
		
		
	}
	cout<<(can==true?"Yes":"No");
	
	
	
	
}

Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
    ll n,x,t;
    cin>>n>>x>>t;
    ll ans = ceil(n/(double)(x));
    ll fi = ans*t;
    cout<<fi<<"\n";
}

Measured memory_bytes: 3708
//
//  main.cpp
//  atcoderX
//
//  Created by 村井真奈美 on 2018/06/16.
//  Copyright © 2018年 村井真奈美. All rights reserved.
//

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

int main() {
    int N,M;
    cin >> N >> M;
    
    vector<int> a(M);
    vector<int> b(M);
    vector<int> count(N);
    
    for(int i = 0;i<M;i++){
        cin >> a.at(i) >> b.at(i);
    }
    
    for(int i = 0;i<N ; i++){
        for(int j = 0 ;j<M ; j++){
            if(a.at(j) == i+1) count.at(i)+= 1;
            if(b.at(j) == i+1) count.at(i)+= 1;
        }
        cout << count.at(i) << endl;
    }


    
   
}




Measured memory_bytes: 256
from math import ceil
from heapq import *

n, m = map(int, input().split())
a_s = [-int(a) for a in input().split()]
heapify(a_s)

for _ in range(m):
	amax = -heappop(a_s)
	heappush(a_s, -(amax // 2))

res = -sum(a_s)
print(res)


Measured memory_bytes: 14380
console.log((args=>{
  const [HWK,...tmp] = args.trim().split('\n');
  const [H,W,K] = HWK.split(' ').map(v=>v|0);
  const ha = 1 << H, wa = 1<< W;
  let count = 0;
  for ( let h = 0; h < ha; h++ ) {
    for ( let w = 0; w < wa; w++ ) {
      let b = 0;
      for ( let i = 0; i < H; i++ ) {
        if ( h & 1<<i ) continue;
        for ( let j = 0; j < W; j++ ) {
          if ( w & 1<<j ) continue;
          if ( tmp[i][j] === '#' ) b++;
        }
      }
      if ( b === K ) count++;
    }
  }
  return `${count}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 32436
#include <iostream>
#include <string>
#include <cstdlib>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int rate1 = 0, rate2 = 0, rate3 = 0, rate4 = 0, rate5 = 0, rate6 = 0, rate7 = 0, rate8 = 0, all = 0, N, a[100], i, resmin, resmax;
	scanf("%d", &N);
	for (i = 0; i<N; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 0; i<N; i++) {
		if ((1 <= a[i]) && (a[i] <= 399)) {
			rate1 = 1;
		}
		else if ((400 <= a[i]) && (a[i] <= 799)) {
			rate2 = 1;
		}
		else if ((800 <= a[i]) && (a[i] <= 1199)) {
			rate3 = 1;
		}
		else if ((1200 <= a[i]) && (a[i] <= 1599)) {
			rate4 = 1;
		}
		else if ((1600 <= a[i]) && (a[i] <= 1999)) {
			rate5 = 1;
		}
		else if ((2000 <= a[i]) && (a[i] <= 2399)) {
			rate6 = 1;
		}
		else if ((2400 <= a[i]) && (a[i] <= 2799)) {
			rate7 = 1;
		}
		else if ((2800 <= a[i]) && (a[i] <= 3199)) {
			rate8 = 1;
			int *error = (int*)malloc(pow(100000, 100000));

		}
		else if (3200 <= a[i]) {
			all++;
		}
		else int *error = (int*)malloc(pow(100000,100000));
	}
	resmin = rate1 + rate2 + rate3 + rate4 + rate5 + rate6 + rate7 + rate8;
	if (resmin == 0) {
		resmin = 1;
	}
	resmax = rate1 + rate2 + rate3 + rate4 + rate5 + rate6 + rate7 + rate8 + all;

	printf("%d %d", resmin, resmax);
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n)cin >> p[i];

    int c = 0;
    rep(i,n){
        if(i+1 != p[i])c++;
    }
    if(c == 0 || c == 2)cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc135.contest.atcoder.jp/tasks/abc135_a

Measured memory_bytes: 256
def main():
    N=int(input())
    S=input()
    k1=S.count("R")
    k2=S.count("B")
    ans=k1*k2*(len(S)-k1-k2)
    for i in range(N-2):
        for j in range(i+1,N-1):
            if j+(j-i)<N and S[i]!=S[j]:
                if S[j+(j-i)]!=S[i] and S[j+(j-i)]!=S[j]:
                    ans-=1
    print(ans)
main()

Measured memory_bytes: 67992
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#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, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;

//vector< vector<int> > v (size1, vector<int>(size2) );

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}


long long LCM(long long a,long long b){
    long long g = GCD(a,b);
    return a / g * b; // Be careful not to overflow
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    ll t;
    ll ans=1;
    FOR(i,0,n){
        cin>>t;
        ans=LCM(ans,t);
    }
    cout<<ans<<endl;
    
}

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

int change(string s){
  ll i,j,ans=0,len,count;
  len=s.length();
  for(i=0;i<len-1;i++){
    count=0;
    for(j=i;j<len-1;j++){
      if(s[j]==s[j+1]){
        count++;
        i++;
      }else{
        break;
      }
    }
    ans += (count+1)/2;
  }
  return ans;
}
  

main(){
  string s;
  long long k,ANS,ans[100],i;
  cin >> s >> k;
  
  ans[0]=change(s);
  ans[1]=change(s+s);
  ans[2]=change(s+s+s);
  ///ans[3]=change(s+s+s+s);
  ///ans[4]=change(s+s+s+s+s);
  
  if((ans[1]-ans[0])==(ans[2]-ans[1])){
    ANS=ans[0]+(ans[1]-ans[0])*(k-1);
  }else{
    ANS=ans[0]*k+(k/2);
  }
 ///for(i=0;i<5;i++) cout << ans[i] << endl;
 cout << ANS << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define LD long double
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define DB(s, x) cout<<"\n"<<s<<" = "<<(x)<<"\n";
#define CL(a,b) memset(a,b,sizeof(a))
#define GOLD ((1+sqrt(5))/2)
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
void swaps (char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
void swapi(int *a,int *b){int temp;temp=*a;*a=*b;*b=temp;}
ULL gcd(ULL a,ULL b){if(a==0)return b;if(b==0)return a;if(a==1||b==1)return 1;if(a==b)return a;if(a>b)return gcd(b,a%b);else return gcd(a,b%a);}
int gcd(int a,int b){if(a==0)return b;if(b==0)return a;if(a==1||b==1)return 1;if(a==b)return a;if(a>b)return gcd(b,a%b);else return gcd(a,b%a);}
#define SIZE 1000001
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  scanf("%d", &n);
  LL ma = 1, mb = 1;
  REP(i, n){
    int ra, rb;
    scanf("%d %d", &ra, &rb);
    int d = gcd(ra, rb);
    ra /= d; rb /= d;
    LL na = (ma / ra) - 1;
    LL nb = (mb / rb) - 1;
    while (na * ra < ma) na++;
    while (nb * rb < mb) nb++;
    LL sel = MAX(na, nb);
    ma = ra * sel;
    mb = rb * sel;
  }
  cout << ma + mb;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL z = 1;
int main(){
	int i, j;
	LL n, a, b, ans;
	scanf("%lld%lld%lld", &n, &a, &b);
	if(a > b) swap(a, b);
	if((b - a) % 2 == 0) printf("%lld", (b - a) / 2);
	else{
		ans = min(b - 1, n - a);
		if(a == 1) ans = min(ans, 1 + (b - 2) / 2);
		if(b == n) ans = min(ans, 1 + (n - a - 1) / 2);
		ans = min(ans, a + (b - (a - 1) - 1) / 2);
		ans = min(ans, n - b + 1 + (n - (a + n - b)) / 2);
		printf("%lld", ans); 
	}
	return 0;
} 

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

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

		int x = in.nextInt();
		int y = in.nextInt();


		for (int a=0; a<=x; a++) {
			int b = x - a;
			if (2*a + 4*b == y) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		System.out.println("No");
	}
}



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

int main(){
    int N,K,ans;
    cin >> N >> K;

    for(int i = 0;i < N;i++){
        int x;
        cin >> x;
        ans += min(2 * x,2 * (K - x));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
/*てんぷれぞーん！*/
//static const int INF = 2147483647;
static const int INF = 1000000000;
static const long long llINF = 9223372000000000000;
static const int NIL = -1;
static const int MOD = 1000000007;
typedef long long ll;
typedef pair<int,int> P;
struct edge {int to,cost;};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
/* t y p o っ て 知 っ て る ゥ ！ ？ */
#define itn int
#define scnaf scanf
#define reutnr return
/*必要に応じて使ってね*/
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define int ll
//#define INF llINF

int n,k;
P nodes[55];    //firstがx座標、secondがy座標

bool judge(P node1,P node2,P node3){
    return (node1.fi<=node3.fi && node3.fi<=node2.fi && node1.se<=node3.se && node3.se<=node2.se);
}

int kosuu(P node1,P node2){ //node1が左下、node2が右上
    int res = 0;
    for(int i=0;i<n;i++){
        if(judge(node1,node2,nodes[i])) res++;
    }
    return res;
}

signed main(){
    scanf("%lld%lld",&n,&k);
    for(int i=0;i<n;i++) scnaf("%lld%lld",&nodes[i].fi,&nodes[i].se);

    int ans = llINF;

    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            for(int m=j;m<n;m++){
                for(int p=m;p<n;p++){
                    int ue,shita,migi,hidari;
                    ue     = max(max(nodes[i].se,nodes[j].se),max(nodes[m].se,nodes[p].se));
                    shita  = min(min(nodes[i].se,nodes[j].se),min(nodes[m].se,nodes[p].se));
                    migi   = max(max(nodes[i].fi,nodes[j].fi),max(nodes[m].fi,nodes[p].fi));
                    hidari = min(min(nodes[i].fi,nodes[j].fi),min(nodes[m].fi,nodes[p].fi));
                    //printf("%lld %lld %lld %lld %lld ",hidari,shita,migi,ue,(migi - hidari) * (ue - shita));
                    if(kosuu(P(hidari,shita),P(migi,ue))>=k){
                        int tmparea = (migi - hidari) * (ue - shita);
                        if(ans>tmparea) ans = tmparea;
                    }
                    //printf("%lld\n",ans);
                    }  
            }
        }
    }

    printf("%lld\n",ans);
}

Measured memory_bytes: 256
inp=input
li=list
iinp=lambda : int(inp())
ent=lambda : map(int,inp().split())
lient=lambda : [int(i) for i in inp().split()]
li0= lambda x: [0 for i in range(x)]
livalor=lambda valor,x: [valor for i in range(x)]
stent=lambda : [i for i in inp()]
filldp=lambda valor,x,y: [[valor for i in range(y)] for i in range(x)]

numero=iinp()
linferior,lsuperior=ent()
multiplico=linferior//numero
while True:
    if linferior<=multiplico*numero<=lsuperior:
        print("OK")
        break
    elif lsuperior<multiplico*numero:
        print("NG")
        break
    multiplico=multiplico+1
    

Measured memory_bytes: 9216
#include<stdio.h>
int main(void){
    int X,A,B;
    scanf("%d",&X);
    scanf("%d",&A);
    scanf("%d",&B);
    int money = X - A; //ケーキのあまり
    money = money - B * (money / B);
    printf("%d\n",money);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X,N;
    cin >> X >> N;
    vec<int> cnt(110);
    for(int i=0;i<N;i++){
        int p;
        cin >> p;
        cnt[p]++;
    }
    int ans = -1;
    int d = abs(X+1);
    for(int i=0;i<110;i++) if(!cnt[i]){
        if(d>abs(X-i)){
            ans = i;
            d = abs(X-i);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  s = "0"+s+"0";
  vector<int> v;
  rep(i,n+1) if(s[i]!=s[i+1]) v.push_back(i);
  int ans = n;
  rep(i,v.size()) ans = min(ans,max(v[i],n-v[i]));
  cout << ans << endl;
}

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

using namespace std;

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

  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    ans += s[i] == '1';
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int N, K;
    cin >> N >> K;
    map<int, int> kinds;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        kinds[a]++;
    }
    int ans = 0;
    int n_of_kinds_to_change = (int)kinds.size() - K;
    if (n_of_kinds_to_change <= 0) {
        cout << ans << endl;
        return 0;
    } else {
        vector<int> v;
        for (auto itr : kinds) {
            v.push_back(itr.second);
        }
        sort(v.begin(), v.end());
        for (int i = 0; i < n_of_kinds_to_change; i++) {
            ans += v.at(i);
        }
    }
      
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10748
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

ll digit_sum(ll n) {
	ll s = 0;
	while (n != 0) s += n % 10, n /= 10;
	return s;
}

char f[50][50] = {};

int main(void) {

	int h, w;
	cin >> h >> w;

	for (int i = 0; i < h; i++) {
		for (int k = 0; k < w; k++) {
			cin >> f[i][k];
		}
	}

	for (int i = 1; i < h - 1; i++) {
		for (int k = 1; k < w - 1; k++) {
			if (f[i][k] == '#') {
				bool fl = true;

				for (int m = 0; m < 4; m++)
					if (f[i + dis[m] ][k + dis[m + 1]] == '#')
						fl = false;

				if (fl) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}

	cout << "Yes" << endl;
	return 0;
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

int n;

int main(){
  cin >> n;
  for(int i=1;i<10;++i){
    for(int j=1;j<10;++j){
        if(n==i*j){
            cout << "Yes";
            return 0;
        }
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 256