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

using namespace std;

int main(){
    int n;
    int m;
    int x;
    int cost;
    int a;
/*
    int *a;
    a = new int[m];
*/
    cin >> n >> m >> x;
    for(int i = 0;i<m;i++){
        //cin >> a[i];
        cin >> a;
        if(x <= a){
            cost = min(i,m-i);
            break;
        }
    }

    cout << cost;

    //delete[] a;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,k;
  cin>>a>>b>>k;
  if(a-k>=0){
    cout<<a-k<<" "<<b<<endl;
  }
  else if(a-k<0 && a+b-k>=0){
    cout<<0<<" "<<b-(k-a)<<endl;
  }
  else if(a+b<k){
    cout<<0<<" "<<0<<endl;
  }
}

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

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


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int a, b;

scanf("%d %d" ,&a, &b);

if(a < b){
printf("a < b\n");
}
if(a > b){
printf("a > b\n");
}
if(a == b){
printf("a == b\n");
}
return 0;
}


Measured memory_bytes: 2592
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int H,W,N;
map<int,vector<int> >S;
LL Count(const vector<int>&s,const int l,const int r){assert(l<=r);return upper_bound(s.begin(),s.end(),r)-lower_bound(s.begin(),s.end(),l);}
int main()
{
//	freopen("in.txt","r",stdin);
	while(scanf("%d%d%d",&H,&W,&N)==3)
	{
		S.clear();
		set<pair<int,int> >all;
		for(int a,b,i=0;i<N;i++)
		{
			scanf("%d%d",&a,&b),S[a].push_back(b);
			for(int j=0;j<3;j++)for(int k=0;k<3;k++)if(1<=a-j&&a-j+2<=H&&1<=b-k&&b-k+2<=W)all.insert(make_pair(a-j,b-k));
		}
		for(auto &p:S)
		{
			vector<int>&s=p.second;
			sort(s.begin(),s.end()),s.resize(unique(s.begin(),s.end())-s.begin());
		}
		static LL ans[10];
		for(int i=0;i<=9;i++)ans[i]=0;
		for(const auto &p:all)
		{
//			printf("(%d,%d)\n",p.first,p.second);
			LL cnt=0;
			for(int i=0;i<3;i++)cnt+=Count(S[p.first+i],p.second,p.second+2);
//			printf("cnt=%lld\n",cnt);
			assert(1<=cnt&&cnt<=9);
			++ans[cnt];
		}
		ans[0]=(W-2LL)*(H-2LL);
		for(int i=1;i<=9;i++)ans[0]-=ans[i];
		for(int i=0;i<=9;i++)printf("%lld\n",ans[i]);
	}
	return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<vector<int>> A(N, vector<int>(N));
  priority_queue<tuple<int,int,int>> pq;
  long long ret = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A[i][j];
      if (i > j) {
        pq.emplace(A[i][j], i, j);
        ret += A[i][j];
      }
    }
  }
  vector<vector<int>> orgA = A;
  vector<vector<int>> count(N, vector<int>(N));
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
        if (A[i][j] == A[i][k] + A[k][j]) {
          if (i != k && j != k) {
            if (A[i][j] == A[i][k] + A[k][j])
              count[i][j]++;
          }
        }
      }
    }
  }
  bool ok = true;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (A[i][j] != orgA[i][j]) ok = false;
    }
  }
  if (!ok) {
    cout << -1 << endl;
    return 0;
  }

  while (!pq.empty()) {
    vector<long long> dist(N);
    fill(dist.begin(), dist.end(), 1e18);
    tuple<int,int,int> t = pq.top(); pq.pop();
    int val = get<0>(t);
    int v1 = get<1>(t), v2 = get<2>(t);
    if (count[v1][v2]) {
      ret -= val;
    }
  }
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 1912
S = input()
 
N = len(S)
Y = 753
ans =abs( Y - (int(S[0]) * 100 + int(S[1]) * 10 + int(S[2])))
 
for i in range(3,N):
    ans = min(ans, abs(Y - (int(S[i-2]) * 100 + int(S[i-1]) * 10 + int(S[i]))))
    
print(ans)
    

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int x, y;
    std::cin >> x >> y;
    if (y % 2 == 0 && y / 2 - x >= 0 && 2 * x - y / 2 >= 0) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; ++i) cin >> p[i];
  int ans = 0;
  for(int i = 1; i < n-1; ++i){
    ans += (p[i] != min({p[i],p[i-1],p[i+1]}) and
            p[i] != max({p[i],p[i-1],p[i+1]}));
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int[] N = cin.ArrayInt(2,0);
        if(N[0]>N[1])Console.WriteLine("a > b");
        else if(N[0]<N[1])Console.WriteLine("a < b");
        else Console.WriteLine("a == b");
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n];
	
	for(int i=n-1; i>=0 ; i--){
		cin>>a[i];
	}
	
	for(int i=0 ; i<n ; i++ ) {
	  cout<<a[i];
	  if ( i==n-1){break;}
	  cout<<" ";
	}
    cout<<endl;
  
	return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (abs(A - C) <= D || (abs(A - B) <= D && abs(B - C) <= D)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int a[205];
int main()
{
 int n,ans=0;
 scanf("%d",&n);
 for(int i=1;i<=2*n;i++)
  scanf("%d",&a[i]);
 sort(a+1,a+2*n+1);
 for(int i=1;i<=2*n;i+=2)
  ans+=a[i];
 printf("%d\n",ans);
 return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

int n,m,a,b;

signed main(){
	read(n,m,a,b);
    for(int i=1;i<=n;i++,puts("")) for(int j=1;j<=m;j++) write((i<=b&&j<=a)||(i>b&&j>a));
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int p[200005];
char pp[200020];
vector<int>v;
main()
{
	scanf("%s",&pp[1]);
	for(int i = 1;pp[i];i++)
	{
		if(pp[i]=='T')
		{
			v.push_back(i);
		}
	}
	int co=0,cou=0;
	for(int i = 1;pp[i];i++)
	{
		if(pp[i]=='S')
		{
			if(co<v.size())
			{
				cou++;
				co++;
			}
		}
		while(co<v.size() && v[co]<=i)
		{
			co++;
		}
	}
	int ppp=strlen(&pp[1]);
	printf("%d",ppp-2*cou);
}
/*
  SSSTTSTTST
  */

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

#define int long long

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

constexpr ll INF = 1e18;

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

  int n;
  cin >> n;
  ++n;
  vi a(n);
  trav(i, a) cin >> i;

  ll rem = 1;
  vector<ll> maxat(n);
  rep(i, 0, n) {
    if (rem == 0){cout << -1 << '\n'; exit(0);}
    maxat[i] = rem;
    rem -= a[i];
    if (rem < 0){cout << -1 << '\n'; exit(0);}
    rem *= 2;
    rem = min(rem, INF);
  }
  ll sol = 0;
  ll have = 0;
  for (int i = n - 1; i >= 0; i--) {

    have += a[i];
    have = min(maxat[i], have);
    sol += have;
  }
  cout << sol << '\n';
  
}


Measured memory_bytes: 5036
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            if (a % 2 == 0 || b % 2 == 0)
            {
                WriteLine("Even");
            }
            else
            {
                WriteLine("Odd");
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
	int A, B, T; cin >> A >> B >> T;
	cout << (T / A) * B << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
count = gets.to_i
a = gets.split.map(&:to_i)

s = 0
res = 0
left = 0

count.times do |i|
  until (s & a[i]) == 0
    s ^= a[left]
    left += 1
  end
  
  s ^= a[i]
  
  res += i - left + 1
end

puts res

Measured memory_bytes: 15364
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;


int main() {
  ll h,w,n;
  cin>>h>>w>>n;
  ll Max=max(h,w);
  ll s=n/Max;
  if(Max*s==n){cout<<s<<endl;}
  else{cout<<s+1<<endl;}
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  bool ok = false;
  while (n) {
    if (n % 10 == 7) ok = true;
    n /= 10;
  }
  std::cout << (ok ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b) for (int i=(a); i<(b); i++)

int fac(int x){
	int ans=1;
	For(i,1,x+1){
		ans*=i;
	}
	return ans;
}

int order(int n){
	int a[n];
	For(i,0,n)
		cin>>a[i];
	int ans=0;
	For(i,0,n){
		int cnt=0;
		For(j,0,i)
			if (a[j]<=a[i])
				cnt++;
		ans+=(a[i]-cnt)*fac(n-i-1);
	}
	return ans+1;
}

int main(){
	int n;
	cin>>n;
	int a=order(n), b=order(n);
	cout<<abs(a-b);
	return 0;
}

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

using namespace std;
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
  
signed main() {
  vector<bool> A(100100,true);
  for(int i=2;i<=100010;i++){
    int up=sqrt(i)+1;
    for(int j=2;j<up;j++){
      if(i%j==0){
         A[i]=false;
        break;
      }
    }
  }

  vector<int> B(50050);
  for(int i=3;i<=100010;i+=2){
    B[i/2]=B[(i-2)/2];
    if(A[i]&&A[(i+1)/2]){
      B[i/2]++;
    }
  }
  int q;
    scanf("%d",&q);
  for(int i=0;i<q;i++){
    int l,r;
      cin>>l>>r;
    if(l==1){
      l+=2;
    }
    printf("%d\n",B[r/2]-B[(l-2)/2]);
  }
}


Measured memory_bytes: 896
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 200100;

    void solve(){
        ll n, cnt = 0;
        cin >> n;
        repA(i, 1, n){
            ll k = i, si = 0;
            while(k) k/=10, si++;
            si%2 ? cnt++:0;
        }
        cout << cnt << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
     /*
      #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
      #endif
     */
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int num;
	scanf("%d", &num);
	vector<int>v;
	for (int i = 0; i < num * 3; i++)
	{
		int z;
		scanf("%d", &z);
		v.push_back(z);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	long long s = 0;
	for (int i = 0; i < num; i++)s += v[i * 2 + 1];
	printf("%lld\n", s);
}

Measured memory_bytes: 2420
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func abs(a int, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func chmin(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func chmax(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	k := nextInt()
	heights := nextInts(n)
	dp := make([]int, n)
	for i := range dp {
		dp[i] = math.MaxInt32
	}

	for i := range dp {
		if i == 0 {
			dp[i] = 0
		}

		for j := 1; j <= k; j++ {
			if i+j < n {
				dp[i+j] = chmin(dp[i+j], dp[i]+abs(heights[i], heights[i+j]))
			} else {
				break
			}
		}
	}

	fmt.Println(dp[n-1])
}


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

#define endl '\n'
typedef long long ll;
const ll maxn=1e5+1;

ll n, a[maxn], dp[maxn][2];

int main()   // 0/1穷举？ 贪心？ DP?如何DP? 
{
	cin>>n;
	
	for(ll i=0;i<n;i++)
	   cin>>a[i];
	
	dp[0][0] = a[0];
	dp[0][1] = -a[0];
	
	for(ll i=1; i<n; i++)
	{
		dp[i][0] = max(dp[i-1][0]+a[i], dp[i-1][1]-a[i]);
		dp[i][1] = max(dp[i-1][0]-a[i], dp[i-1][1]+a[i]);
	}
	
	cout << dp[n-1][0] << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int n,a,b; cin >> n >> a >> b;
    int ans=min(a*n,b);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, A, B = map(int, input().split())

    MaxAns = min(A, B)
    MinAns = 0
    if N >= A + B:
        pass
    else:
        MinAns = -(N - A - B)

    print(MaxAns, MinAns)


if __name__ == '__main__':
    main()


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


int main() {
	int N;
	long long A;
	long long res = 0;

	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A;
		res = res + A - 1;
	}

	cout << res << endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
list = []
for i in range(k):
    d = input()
    list.append(input().split())
cnt = 0
for i in range(n):
    a = str(i + 1)
    flg = False
    for l2 in list:
        if a in l2:
            flg = True
            break
    if not flg:
        cnt += 1

print(cnt)

Measured memory_bytes: 9360
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    int N,K,S;
    int mod = 1e9;
    cin >> N >> K >> S;
    rep(i,K){
        cout << S << " ";
    }
    rep(i,N-K){
        if(S==1){
            cout << mod << " ";
        }else{
            cout << S-1 << " ";
        }
    }
}

Measured memory_bytes: 1280
def resolve():
    N = int(input())
    S = str(input())
    cnt = 0

    for i in range(1000):
        c = [int(i / 100), int(i / 10) % 10, int(i % 10)]
        f = 0

        for j in range(N):
            if S[j] == ('0' + str(c[f])) or S[j] == str(c[f]):
                f += 1
            if f == 3:
                break

        if f == 3:
            cnt += 1
    print(cnt)
    return

resolve()

Measured memory_bytes: 73900
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll N;
	cin >> N;
	
	vector<ll> A(N + 1);
	rep(i, N + 1) {
		cin >> A[i];
	}

	ll b;
	rep(i, N) {
		cin >> b;
		if (A[i] > b) {
			ans += b;
			A[i] -= b;
		}
		else {
			ll temp = b - A[i]; // 持ち越し
			if (A[i + 1] < temp) {
				ans += A[i] + A[i + 1];
				A[i + 1] = 0;
			}
			else {
				ans += b;
				A[i + 1] -= temp;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
def f a, m
  x, n = 1, 1
  until (x = (a * x) % m) == 1
    n += 1
  end
  return n
end

loop do
  input = gets.split.map(&:to_i)
  if input == [0] * 6
    break
  end
  a1, m1, a2, m2, a3, m3 = *input
  nx = f a1, m1
  ny = f a2, m2
  nz = f a3, m3
  n = [nx, ny, nz].inject{|x, y|x.lcm y}
  puts n
end

Measured memory_bytes: 6120
def main():
    from sys import stdin
    readline = stdin.readline
    H, N = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(N)]

    dp = [100000000] * (H + 10 ** 4 + 1)
    dp[0] = 0
    for i in range(H):
        if dp[i] == 100000000:
            continue
        for a, b in AB:
            t = dp[i] + b
            if t < dp[i + a]:
                dp[i + a] = t
    print(min(dp[H:]))


main()


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define yes { cout << "YES" << endl; exit(0); }
#define no { cout << "NO" << endl; exit(0); }
#define impossible { cout << "Impossible" << endl; exit(0); }

using namespace std;

typedef long long ll;
typedef pair<int,int> Pair;

int main()
{
  //  freopen("inputA", "r", stdin);
    // freopen("output", "w", stdout);
    cin.sync_with_stdio(false); cin.tie(0);
    
    int n;
    cin >> n;
    cout << (n-1) / 2 << '\n';

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

int main(){
    ll x,d,k;
    cin >> x >> k >> d;
    if(x<0)x *= -1;
    if(x/d > k){
        cout << x-k*d << endl;
    }
    else{
        k -= x/d;
        ll ans = x - (x/d)*d;
        if(k%2==1) ans = d-ans;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int dp[105][2][4];

int main() {
    string s; cin >> s;
    int k; cin >> k;
    int x = s.size();
    dp[0][0][0] = 1;
    for (int i = 0; i < x; i++) {
        for (int smaller = 0; smaller < 2; smaller++) {
            for (int j = 0; j <= k; j++) {
                int nd = s[i] - '0';
                rep(d,10) {
                    int ni = i + 1, ns = smaller, nj = j;
                    if (ns == 0) {
                        if (d > nd) continue;
                        if (d < nd) ns = 1;
                    }
                    if (d != 0) nj++;
                    if (nj > k) continue;
                    dp[ni][ns][nj] += dp[i][smaller][j];
                }
            }
        }
    }
    cout << dp[x][0][k] + dp[x][1][k] << endl;
}

Measured memory_bytes: 256
//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 100009
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
    	ll n,m,x,i,l,j,k,c=0,ans=0;
    	string s,t;
    	cin>>s>>t;
    	l=s.size();
    	f(i,l)
    	{
    	    if(s[i]!=t[i])
                c++;
    	}
    	cout<<c;
}





Measured memory_bytes: 3852
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char a[110],b[110];
int len1,len2;
bool cmp1(char x,char y)
{
	return x<y;
}
bool cmp2(char x,char y)
{
	return x>y;
}
int main()
{
	scanf("%s%s",a,b);
	len1=strlen(a);
	len2=strlen(b);
	sort(a,a+len1,cmp1);
	sort(b,b+len2,cmp2);
	for(int i=0;i<min(len1,len2);++i)
	{
		if(a[i]<b[i])
		{
			printf("Yes\n");
			return 0;
		}
		else if(a[i]>b[i])
		{
			printf("No\n");
			return 0;
		}
	}
	if(len1>=len2)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
	return 0;
}

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

template<class T> inline void chmax(T & a, T b) { if (a < b) a = b; }
template<class T> inline void chmin(T & a, T b) { if (a > b) a = b; }

const long long INF = 1LL << 60;
using namespace std;

int main() {
	int N; cin >> N;
	long long dp[110000];
	for (int i = 0; i < 110000; i++) dp[i] = INF;

	dp[0] = 0;
	for (int n = 1; n <= N; n++) {
		for (int pow6 = 1; pow6 <= n; pow6 *= 6) {
			chmin(dp[n], dp[n - pow6] + 1);
		}
		for (int pow9 = 1; pow9 <= n; pow9 *= 9) {
			chmin(dp[n], dp[n - pow9] + 1);
		}
	}

	cout << dp[N] << endl;

	return 0;
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    cout<<a*b<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
string s, t;

void solve()
{
    cin>> s >> t;
    int ans = 0;
    for (int i = 0; i < s.length();++i)
    {
        if(s[i]!=t[i])
            ans++;
    }
    printf("%d\n", ans);
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define taskname "A"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
const ll inf = 1e18;
int dp[maxn][2];
vector<int> adj[maxn];
int n,k;
int a[maxn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP" , "r")){
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    fill_n(a,maxn,-1);
    cin >> n;
    for(int i = 1 ; i < n ; ++i){
        int u , v;cin >> u >> v;
        adj[u].pb(v);adj[v].pb(u);
    }
    cin >> k;
    int root = 0;
    for(int i = 1 ; i <= k ; ++i){
        int v , p;cin >> v >> p;
        a[v] = p;
        root = v;
    }
    bool found = 1;
    function<void(int,int)> DFS = [&](int u , int par){
        dp[u][0] = -1e9 , dp[u][1] = 1e9;
        for(int c : adj[u]){
            if(c == par)continue;
            DFS(c , u);
            dp[u][0] = max(dp[u][0] , dp[c][0] - 1);
            dp[u][1] = min(dp[u][1] , dp[c][1] + 1);
        }
        if(dp[u][0] > dp[u][1])found = 0;
        if(a[u] != -1 && (dp[u][1] < a[u] || a[u] < dp[u][0]))found = 0;
        if(a[u] != -1)dp[u][0] = dp[u][1] = a[u];
//        cout << u << " " << dp[u][0] << " " << dp[u][1] << endl;
    };
    function<void(int,int)> Col = [&](int u , int par){
        for(int c : adj[u]){
            if(c == par)continue;
            if(dp[c][0] <= a[u] + 1 && dp[c][1] >= a[u] + 1){
                a[c] = a[u] + 1;
            }else if(dp[c][0] <= a[u] - 1 && dp[c][1] >= a[u] - 1){
                a[c] = a[u] - 1;
            }else{
                found = 0;
            }
//            cout << dp[c][0] << " " << dp[c][1] << " " << a[c] << endl;
//            cout << c << " " << a[c] << endl;
//            cout << u << " " << c << " " << found << endl;
            Col(c , u);
        }

    };
    DFS(root , 0);
    if(found == 0)return cout << "No" , 0;
    Col(root , 0);
    if(found == 0)return cout << "No" , 0;
    cout << "Yes\n";
    for(int i = 1 ; i <= n ; ++i)cout << a[i] << '\n';
}


Measured memory_bytes: 19712
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
 int n,c=0;
   cin >> n;
   ll sum=0;
   for(int i=1;i<=n;i++){
     for(int j=1;j<=n;j++){
       for(int k=1;k<=n;k++){
         sum = sum +__gcd(i,__gcd(j,k));
       }
     }
   }
  cout  << sum <<"\n";
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


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;
}
ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    cout << u << endl;
    return u;
}

 
int main() {
    int x;
    cin >> x;
    cout << 10 - x/200 << endl;
    
}



Measured memory_bytes: 3632
#include<stdio.h>
#define MAX 2001
#define INF 100000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n;
int A[MAX][MAX],d[MAX],col[MAX];

void dikstra(){
  int u,i,j,k,mini;

  for(i=0; i<n; i++){
    col[i] = WHITE;
    d[i] = INF;
  }
  d[0] = 0;
  col[0] = GRAY;

  while(1){
    mini = INF;
    for(i=0; i<n; i++){
      if(col[i] != BLACK && d[i]< mini){
	mini = d[i];
	u = i;
      }
    }
    if(mini == INF)break;
    col[u] =BLACK;

    for(j=0; j<n; j++){
      if(col[j] != BLACK && A[u][j] < d[j]){//ここが(A[][] < d[j]になってた)
	if(d[u] + A[u][j] < d[j]){
	  d[j] = d[u] + A[u][j];
	  col[j] = GRAY;
	}
      }
    }
  }
  for(i=0; i<n; i++){
    if(d[i]==INF)printf("%d %d\n",i,-1);
    else printf("%d %d\n",i,d[i]);
  }
}


int main(){
  int i,j,min,k,v,c,u;
  
  scanf("%d",&n);
  //配列A[][]に全部INFを投下
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      A[i][j]=INF;
    }
  }
  //表に入れる
  for(i=0; i<n; i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k; j++){
      scanf("%d %d",&v,&c);
      A[u][v] = c;
    }
  }
  dikstra();

  return 0;
}



Measured memory_bytes: 2136
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k, x;
    cin >>k >>x;
    if(500 * k >= x)
        cout <<"Yes";
    else 
        cout <<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm> 
#define MAX(a,b) a>b?a:b
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;

int main(){
    int Q;
    int N;
    scanf("%d",&Q);
    rep(i,Q){
        int count = 0;
        scanf("%d",&N);
        while(N>=10){
            int temp = N;
            int digit = 0;
            while(temp>0){
                digit++;
                temp/=10;
            }
            count++;
            temp = 10;
            int max = 0;
            rep(i,digit-1){
                max = MAX(max,(N/temp)*(N%temp));
                temp*=10;
            }
            N = max;
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 1192
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <algorithm>
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#include <math.h>
#define ld long double
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>

int main()
{
   int n,d;
   cin>>n>>d;
   int ans = (n + d* 2) / (d * 2 + 1);
   cout<<ans<<endl;
    return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント:
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
# coding: utf-8
N=int(input())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if N%2==1:
    print(B[N//2]-A[N//2]+1)
else:
    print(B[N//2-1]-A[N//2-1]+B[N//2]-A[N//2]+1)


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

using namespace std;

int main()
{
    string s;
    map<char,int> mp;
    cin>>s;
    int f=1;
    for(int i=0;i<s.size();i++)
    {
        mp[s[i]]++;
        if(mp[s[i]]>2||mp.size()>2) {f=0;break;}
    }
    if(f==1) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define repi(i, a, b) for (long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()

using namespace std;

int main()
{
    int a, b, c, d, train, bus;
    cin >> a >> b >> c >> d;
    train = min(a, b);
    bus = min(c, d);
    cout << train + bus << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
long long  INF=1'0000'0000'0000'0000'00;
using namespace std;

int main(){

string s;
cin >>s;
int k=s.size();
long long ans=0;
bool Ma=false;
for(int i=1;i<k;i++){
if(s[i]!='9'){
Ma=true;
}

}
if(!Ma){
ans=(s[0]-'0')+9*(k-1);
}
else{
    ans=(s[0]-'0')+9*(k-1)-1;
}
cout<<ans<<endl;

    

 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

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

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

char mp[100][100];

int main()
{
	int h,w;cin>>h>>w;
	int num = 0;
	REP(i,100)REP(j,100)mp[i][j] = '.';
	REP(i,h)REP(j,w){cin >> mp[i][j];if(mp[i][j] == '#')num++;}
	
	int sx = 0,sy = 0;
	int tmp = 1;
	
	while(1)
	{
		if(sx == w-1&&sy == h-1)
		{
			if(tmp == num)
			{
				cout << "Possible" << endl;
				return 0;
			}
			else
			{
				cout << "Impossible" << endl;
				return 0;
			}
		}
		int a = sx,b = sy,cou = 0;
		if(mp[b][a+1] == '#')
		{
			cou++;sx++;
		}
		if(mp[b+1][a] == '#')
		{
			cou++;sy++;
		}
		if(cou != 1)
		{
			cout << "Impossible" << endl;
			return 0;
		}
		tmp++;
	}
	
	return 0;
}


Measured memory_bytes: 256
import sys


class BinaryIndexedTree:
    def __init__(self, n, MOD):
        self.size = n
        self.tree = [0] * (n + 1)
        self.depth = n.bit_length()
        self.MOD = MOD

    def sum(self, i):
        s = 0
        while i > 0:
            s = (s + self.tree[i]) % self.MOD
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] = (self.tree[i] + x) % self.MOD
            i += i & -i

    def lower_bound(self, x):
        sum_ = 0
        pos = 0
        for i in range(self.depth, -1, -1):
            k = pos + (1 << i)
            if k <= self.size and sum_ + self.tree[k] < x:
                sum_ += self.tree[k]
                pos += 1 << i
        return pos + 1, sum_


n, k, *lr = map(int, sys.stdin.buffer.read().split())
lr = list(zip(lr[0::2], lr[1::2]))
MOD = 998244353

bit = BinaryIndexedTree(n + 2, MOD)
bit.add(1, 1)
for i in range(1, n):
    v = bit.sum(i)
    for l, r in lr:
        bit.add(i + l, v)
        bit.add(min(i + r + 1, n + 1), -v)

print((bit.sum(n) - bit.sum(n - 1)) % MOD)


Measured memory_bytes: 74188
#include <iostream>
using namespace std;
typedef long long int ll;
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	double a,b,c,d,e,f; 
	while(cin >> a >> b >> c >> d >> e >> f){
		double y=(c*d-a*f)/(b*d-a*e);
    	double x=(c-b*y)/a;
    	printf("%.3lf %.3lf\n",x,y);
	}
}



Measured memory_bytes: 3228
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
long long MOD = 1000000007;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
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) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int K;cin >> K;
    int T;cin >> T;
    
    vector<int> cake(T);
    for(int i = 0;i<T;i++) cin >> cake.at(i);
    sort(cake.begin(),cake.end(),greater<int>());
    if(T == 1){
        cout << K-1 << endl;
        return 0;
    }
    int maxi = cake.at(0);
    int sum = 0;
    for(int i = 1;i<T;i++){
        sum += cake.at(i);
    }
    if(maxi >= sum){
        cout << max(maxi-sum-1,0) << endl;
    }
    else{
        cout << 0 << endl;
    }
    
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
int main(){
  int H,h,M,m,K,d,ans;
  scanf("%d %d %d %d %d",&H,&M,&h,&m,&K);
  d=(h-H)*60+m-M;
  ans=d-K;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
 
using namespace std;

map < pair<string, string> , int> mp; 

int main() 
{
    int n;
    long long ans = 0;
    string s;
    cin >> n >> s;
    for(int i = 0;i < 1 << n;i ++) 
    {
        string a = "";
        string b = "";
        for(int j = 0; j < n; j ++) 
        {
            if((i >> j) % 2 == 0)
            	a += s[j];
            else 
            	b += s[j];
        }
        mp[{a,b}]++;
    }
    for(int i = 0;i < (1 << n); i++) 
    {
        string a = "";
        string b = "";
        for(int j = 0; j < n;j++) 
        {
            if ((i >> j) % 2 == 0)
            	a += s[n * 2 - 1 - j];
            else 
            	b += s[n * 2 - 1 - j];
        }
        ans += mp[{a,b}];
    }
    cout << ans;
}

Measured memory_bytes: 91904