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

using namespace std;

const int INF = 1e9 + 19;
const int maxSize = 1e5 + 17;

int go[4];

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

    for(int i = 0; i < 3; ++i)
    {
        int x, y;
        cin >> x >> y;

        ++go[x - 1], ++go[y - 1];
    }


    sort(go, go + 4);

    if(go[0] == 1 && go[1] == 1 && go[2] == 2 && go[3] == 2)
        cout << "YES\n";
    else
        cout << "NO\n";







}






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

int main() {
  int n;
  cin >> n;
  int i;
  for (i = 0; i < n; i++) {
    int r, t;
    cin >> r >> t;
    vector<int> r_element;
    r_element.push_back(r / 100);
    r_element.push_back((r + 99) / 100);
    if (r_element[0] == r_element[1]) r_element.pop_back();
    vector<int> t_element;
    t_element.push_back(t / 30);
    t_element.push_back((t + 29) / 30);
    if (t_element[0] == t_element[1]) t_element.pop_back();
    vector<int> result;
    int j, k;
    for (j = 0; j < r_element.size(); j++) {
      for (size_t k = 0; k < t_element.size(); k++) {
        result.push_back(r_element[j] + t_element[k] * 5);
      }
    }
    sort(result.begin(), result.end());
    for (j = 0; j < result.size(); j++) {
      cout << result[j];
      if (j != result.size() - 1) {
        cout << ' ';
      }
    }
    cout << endl;

  }
  return 0;
}



Measured memory_bytes: 3100
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()

	fmt.Fprintln(stdout, n/2+n%2)
}


Measured memory_bytes: 1740
#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>

using namespace std;

int main() {

	int n;
	cin>>n;
	int cont=0;
	int ans=0;
	for(int i=0;i<n;i++){
		int num;
		cin>>num;
		if(num==(i+1)){
			cont++;
		}else{
			ans+=((cont+1)/2);
			cont=0;
		}
	}
	ans+=((cont+1)/2);
	cout<<ans<<endl;



	return 0;

}


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

int main() {
    int X,Y;
    cin>>X>>Y;
    if(X%Y==0){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=1;;i++){
        if(i*X%Y!=0){
            cout<<i*X;
            return 0;
        }
    }
return 0;}
/*
g++ code.cpp
./a.out
*/

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

class edge {
public:
  i64 from, to, length;
  edge(const i64 from, const i64 to, const i64 length) :
    from(from), to(to), length(length) {
  }
};

int main() {
  i64 N;
  std::cin >> N;
  std::vector<std::vector<edge>> edges(N);
  for (i64 i = 0; i < N - 1; ++i) {
    i64 u_i, v_i, w_i;
    std::cin >> u_i >> v_i >> w_i;
    --u_i;
    --v_i;
    edges[u_i].emplace_back(u_i, v_i, w_i);
    edges[v_i].emplace_back(v_i, u_i, w_i);
  }

  std::vector<char> answers(N);
  std::vector<bool> touched(N, false);
  std::queue<i64> queue;
  answers[0] = '0';
  touched[0] = true;
  queue.push(0);
  while (!queue.empty()) {
    const i64 from = queue.front();
    queue.pop();
    for (const edge& edge : edges[from]) {
      if (!touched[edge.to]) {
        answers[edge.to] = '0' + ((answers[edge.from] - '0') ^ (edge.length % 2));
        touched[edge.to] = true;
        queue.push(edge.to);
      }
    }
  }

  for (const char& answer : answers) {
    std::cout << answer << std::endl;
  }
  return 0;
}

Measured memory_bytes: 9472
import java.util.Scanner;

    public class Main {
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		int h = sc.nextInt();
    		int w = sc.nextInt();
    		for(int i=0;i<h;i++) {
    			String c = new String(sc.next());
    			System.out.println(c);
    			System.out.println(c);
    		}
    	}
    }

Measured memory_bytes: 23764
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<pair<int, char>> v_sc(m);
  for (int i = 0; i < m; i++) {
    cin >> v_sc[i].first >> v_sc[i].second;
    v_sc[i].first--;
  }

  int min_n = n == 1 ? 0 : pow(10, n - 1), max_n = pow(10, n) - 1;
  int ans = -1;
  for (int i = min_n; i <= max_n; i++) {
    string si = to_string(i);
    bool matches = true;
    for (auto &p : v_sc) {
      if (p.first >= si.size() || p.second != si[p.first]) {
        matches = false;
        break;
      }
    }

    if (matches) {
      ans = ans == -1 ? i : min(ans, i);
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>

int main()
{
    int N, K;
    std::cin >> N >> K;
    std::vector<int> h(N);
    
    for (auto i=0; i<N; ++i)
    {
        int H;
        std::cin >> H;
        h[i] = H;
    }

    if (N < K)
    {
        std::cout << 0;
        return 0;
    }

    std::sort(h.begin(), h.end(), std::greater<int>());

    long long hEx = 0;
    for (auto i=0; i<N-K; ++i)
        hEx += h[K + i];

    std::cout << hEx;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<climits> //INT_MIN/MAX
using namespace std;

#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(ll (i)=(s);(i)>(e);(i)--)
#define MOD 1000000007
#define llong long long
#define debug(x) cout<<#x<<": "<<x<<endl
typedef long long ll;
llong N;

/* 2017/01/18 問題 -----  abc052 b /Link ----- */
/* -----解説等-----
問題:


*/

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

    string S;
    cin >> N >> S;
    int cnt = 0;
    int ans = 0;
    FOR(i, 0, N) {
        if (S[i] == 'I') {
            cnt++;
            ans = max(ans, cnt);
        }
        else cnt--;
    }
    cout << ans<< endl;

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  string s;cin>>s;
  ll n=s.size();
  string a=s.substr(0,(n-1)/2);
  string b=s.substr((n+1)/2,(n-1)/2);
  string s1=s;
  string a1=a;
  string b1=b;
  reverse(s.begin(),s.end());
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  if(s==s1&&a==a1&&b==b1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <cstdlib>
using namespace std;

template <class T> int streamvar(std::istream& in, T& var)
{
    if (!in) {
        return 1;
    }
    in >> var;
    if (in.fail()) {
        return 1;
    }
    return 0;
}
template <class T> int streamvec(std::istream& in, std::vector<T> &v)
{
    v.clear();
    string s;

    if (!in) {
        return 1;
    }
    getline(in, s);
    if (in.fail()) {
        return 1;
    }
    istringstream is(s);
    while (1) {
        T tmp;
        is >> tmp;
        if (is.fail())
            break;
        v.push_back(tmp);
    }
    return 0;
}

int main(void)
{
    vector<int> v;
    int tmp;
    while (!streamvar(cin, tmp)) {
        v.push_back(tmp);
    }
    sort(v.begin(), v.end(), greater<int>());
    for (int i = 0; i < 3; i++) 
        cout << v[i] << endl;
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n;
    
    cout << (n-2)*180 << endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long ll;

/////////////////////////////////DEBUG/////////////////////////////////
void printd(const char* format)
{
  #ifdef DEBUG
    std::cout << format;
  #endif
}
template<typename T, typename... Targs>
void printd(const char* format, T value, Targs... Fargs)
{
  #ifdef DEBUG
    for ( ; *format != '\0'; format++ ) {
        if ( *format == '%' ) {
           std::cout << value;
           printd(format+1, Fargs...);
           return;
        }
        std::cout << *format;

    }
  #endif
}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef DEBUG
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////////////////////////////// YAY /////////////////////////////////
void solve()
{
  // int n; cin>>n;
  std::string s, t;
  std::cin >> s>>t;
  int c= 0;
  for (int i = 0; i < s.size(); i++) {
    if(s[i]!=t[i]) c++;
    /* code */
  }
  std::cout << c << '\n';
}

int main(int argc, char const *argv[]) {
  int t;
  t=1;

  #ifdef DEBUG
    freopen("input.txt","r", stdin);
    clock_t start, end;
    start = clock();
    cin>>t;
  #endif


  for(int i = 1; i<=t; i++)
  {
    // std::cout << "Case "<<i<<": " << '\n';
    solve();
  }

  #ifdef DEBUG
    end = clock();
    double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
    time_taken *= 1000;
    cout << "Time taken by program is : " << fixed << time_taken << setprecision(5);
    cout << " ms " << endl;
  #endif
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
typedef v(vl) vvl;



int main() {
  int n;
  scanf("%d",&n);
  vvl g(n,vl(n));
  ll d = 1;
  srep(x,1,n) {
    vi a;
    set<int> s;
    int l = 1;
    rep(m,x) {
      while (s.count(l)) ++l;
      a.pb(l);
      s.insert(l);
      rep(i,m) {
        s.insert(l+a[i]);
        rep(j,m) s.insert(l+a[i]-a[j]);
      }
    }
    rep(i,x) g[i][x] = g[x][i] = a[i]*d;
    while (sz(a) < 2) a.pb(1);
    reverse(rng(a));
    d *= a[0]+a[1];
  }
  rep(i,n) cout<<g[i]<<endl;

  return 0;
  set<ll> s;
  vi a(n); rep(i,n) a[i] = i;
  do {
    if (a[0] > a.back()) continue;
    ll tot = 0;
    rep(i,n-1) tot += g[a[i]][a[i+1]];
    if (tot >= 1e11) cout<<tot<<endl;
    if (s.count(tot)) cout<<a<<endl;
    s.insert(tot);
  } while (next_permutation(rng(a)));
  return 0;
}






















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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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 (b<a) { a = b; return 1; } return 0; }

template<typename T, typename U>
void print1(T Array, U size) {
  for (int i = 0; i < size; i++) {
    cout << Array[i] << " ";
  }
  cout << endl;
}

template<typename T>
void print(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------

int dp[50];
int n;

void init() {
  dp[1] = dp[2] = dp[3] = 1;
  for (int i = 1; i <= 30; i++) {
    dp[i+1] += dp[i];
    dp[i+2] += dp[i];
    dp[i+3] += dp[i];
  }
}

signed main() {
  init();
  while (1) {
    cin >> n;
    if (n == 0) break;
    int kind = dp[n] / 10;
    int year = kind / 365;
    int days = kind % 365;
    cout << max(1LL, year + (days >= 1)) << endl;
  }

  return 0;
}


Measured memory_bytes: 2984
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */

/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */

int main()
{

	int		N;
	int		i,j, a,b,ba;
	char	s[10000][11];
	int		ans = 0;

	scanf("%d", &N);
	for (i=0; i<N; i++) {
		scanf("%s", s[i]);
		for(j=0; j<10; j++) {
			if (s[i][j+1]==0) break;
			if ((s[i][j]=='A')&&(s[i][j+1]=='B')) ans++;
		}
		s[i][1] = s[i][strlen(s[i])-1];
		s[i][2] = 0;
	}

	a = b = ba = 0;
	for (i=0; i<N; i++) {
		if (s[i][0]=='B') {
			if (s[i][1]=='A') {
				ba++;
			} else {
				b++;
			}
		}
		if ((s[i][1]=='A')&&(s[i][0]!='B')) a++;
	}

	if (DEBUG) printf("a b ba : %d %d %d\n",a,b,ba);
	if (ba==0) ans += min(a,b);
	if (ba!=0) {
		ans += ba-1;
		if (a>0) { ans++; a--; }
		if (b>0) { ans++; b--; }
		ans += min(a,b);
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>

using namespace std;



int main(){

	int table[2001];

	for(int i=0; i < 2001; i++)table[i] = 0;

	for(int a=0; a <= 1000; a++){
		for(int b = 0; b <= 1000; b++){
			table[a+b]++;
		}
	}

	int n,sum;

	while(scanf("%d",&n)!=EOF){
		sum = 0;
		if(n > 4000){
			printf("0\n");
		}else if(n > 2000){
			for(int k=n-2000;k <= 2000; k++){
				sum += table[k]*table[n-k];
			}
			printf("%d\n",sum);
		}else{
			for(int k = 0; k <= n; k++){
				sum += table[k]*table[n-k];
			}
			printf("%d\n",sum);
		}
	}

    return 0;
}

Measured memory_bytes: 2752
// ConsoleApplication8.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//

#include <iostream>
#include <vector>
#include <string>
using namespace std;

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

	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		if (i == n - 1)
		{
			cnt++;
			break;
		}
		cnt++;
		while (s[i] == s[i + 1])
			i++;
	}
	cout << cnt;
}


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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { for (auto& _e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } pre__;



int main(void) {
	ll W, H, x, y;
	cin >> W >> H >> x >> y;

	double ans = (double)W * H / 2;
	if ( x == W || y == H || x == 0 || y == 0) {
		cout << ans << " " << 0 << endl;
		return 0;
	}

	if (x == W / 2 && y == H / 2 && H % 2 == 0 && W % 2 == 0) {
		cout << ans << " " << 1 << endl;
	}
	else {
		cout << ans << " " << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cstring>

using namespace std;

class Fenwick {
public:
	Fenwick(int _N) : N(_N){ memset(v, 0, sizeof(v)); }
private:
	int N;
	int v[300001];
public:
	void add(int val, int p){
		for(int i=p;i<=N;i+=i&-i) v[i] += val;
	}
	int sum(int p){
		int res = 0;
		for(int i=p;i>0;i-=i&-i) res += v[i];
		return res;
	}
};

int main(){
	std::ios_base::sync_with_stdio(false);
	int N, M;
	while(cin >> N >> M){
		Fenwick f(M+1);

		vector<pair<int,int>> r(N);
		for(int i=0;i<N;i++) cin >> r[i].first >> r[i].second;
		sort(r.begin(), r.end(), [](const pair<int,int>& a, const pair<int,int>& b){
				return a.second - a.first < b.second - b.first;
				});
		cout << N << endl;
		int c = 0;
		for(int d=2;d<=M;d++){
			while(c < N && r[c].second - r[c].first < d - 1){
				f.add(1, r[c].first);
				f.add(-1, r[c].second+1);
				++c;
			}
			int res = N - c;
			for(int j=d;j<=M;j+=d) res += f.sum(j);
			cout << res << endl;
		}
	}
}


Measured memory_bytes: 4480
#include<stdio.h>
int X[]={1,1,1,0,0,-1,-1,-1};
int Y[]={1,0,-1,1,-1,1,0,-1};
int main(){
  int h,w,i,j,k,c;
  char s[100][100]={};
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++)scanf("%s",s[i+1]+1);
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      if(s[i][j]=='#')continue;
      for(k=c=0;k<8;k++){
	if(s[i+Y[k]][j+X[k]]=='#')c++;
      }
      s[i][j]='0'+c;
    }
  }
  for(i=0;i<h;i++)printf("%s\n",s[i+1]+1);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int pre[205];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	for(int i=1;i<=200;i++)
		pre[i]=i*i*i*i*i;
	int x;
	cin>>x;
	for(int i=0;i<=200;i++)
		for(int j=0;j<=200;j++)
			if(pre[i]-pre[j]==x)
			{
				cout<<i<<' '<<j<<endl;
				return 0;
			}
			else if(pre[i]+pre[j]==x)
			{
				cout<<i<<' '<<-j<<endl;
				return 0;
			}
	return 0;
}


Measured memory_bytes: 3652
#!/usr/bin/env python3
import sys


YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int):
    print(YES if C <= A + B else NO)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        int t= Integer.parseInt(reader.readLine());

        String[] s=reader.readLine().split(" ");
        int[] num=new int[t+t];

        for (int i = 0; i <s.length ; i++) {
            num[Integer.parseInt(s[i])]++;
        }
        for (int i = 1; i <=t ; i++) {
            System.out.println(num[i]);
        }
    }
}

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

int main()
{
  char x, y;
  cin >> x >> y;
  if(x > y)
  {
    cout << ">" << endl;
  }
  else if(x < y)
  {
    cout << "<" << endl;
  }
  else
  {
    cout << "=" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, w;
    cin >> n >> w;

    vector<int> a(2*n, 0);
    for(int i=1; i<=w/2; ++i)
        ++ a[i+1];
    for(int i=w/2+1; i<w; ++i){
        for(int j=3*i; j<=n; j+=i){
            ++ a[j-w+1];
            -- a[j-i+1];
        }
    }

    int ret = w;
    for(int i=1; i<=n-w+1; ++i){
        ret += a[i];
        cout << ret;
        if(i < n-w+1)
            cout << ' ';
        else
            cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,x;
    cin>>n>>x;
    ll ans=0;
    vector<int> A(n+1,0);
    rep(i,n) cin>>A[i+1];
    rep(i,n){
        if(A[i+1]+A[i]>x) ans+=A[i+1]+A[i]-x,A[i+1]=x-A[i];
    }
    cout<<ans;
}

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

int main() { 	
 int N,K,kk;
 cin >>N>>K;
  
 if(N<6){
   cout <<0<<endl;
 }else if(N<13){
         cout << K/2<< endl;  
    }else{
       cout << K<< endl;  
  }
}


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

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

    if(a < b){
        cout << "a < b" << endl; 
    }
    else if(a > b){
        cout << "a > b" << endl; 
    }
    else{
        cout << "a == b" << endl; 
    }
    return 0;
}





Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int length = sc.nextInt();
        
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        long sum = 0;
        for (int i=0; i<length; i++){
            int num = sc.nextInt();
            
            sum += num;
            if (max < num) { max = num; }
            if (num < min) { min = num; }
        }
        
        System.out.printf("%d %d %d\n", min, max, sum);
        
    }
}



Measured memory_bytes: 40928
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define endl "\n"
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define F(i,a,b) for(int i = a; i < b; i++)
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define inf 1e9
const double pi = 3.141592653589793238460;
#define debug false
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define mod 1000000007 

void solve()
{
    int N;
    cin>>N;
    int dp[N+2];
    for(int i=0;i<=N+1;i++)
        dp[i] = inf;
    
    vector<int> num;
    dp[0] = 0;
    int n1 = 6;
    while(n1<=N)
    {
        num.pb(n1);
        n1 *= 6;
    }
    n1 = 9;
    while(n1<=N)
    {
        num.pb(n1);
        n1 *= 9;
    }
    num.pb(1);
    sort(num.begin(),num.end());

    for(int i=1;i<=N;i++)
    {
        for(auto x:num)
        {
            if(x>i)
                break;
            
            dp[i] = min(dp[i],dp[i-x]+1);
        }
    }
    cout<<dp[N]<<"\n";

}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        // freopen("Test.txt","r",stdin);
        // freopen("Output.txt","w",stdout);
    #endif
    
     // if(debug){watch_is();}
    solve();   
    return 0;
}

Measured memory_bytes: 640
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n;
  cin >> n;
  int ret = (n + 999) / 1000 * 1000 - n;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 
#define CERR if(false) cerr

using namespace std;

int main(){

    string s;
    cin >> s;

    sort(ALL(s));

    cout << ((s == "abc") ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define PI 2*acos(0.0)
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
int main()
{
    FIO;
    int a,b,c,sum=0,k;
    cin>>a>>b>>c>>k;
    sum=min(a,k);
    k-=sum;
    if(k>0)k-=b;
    if(k>0)sum-=k;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3652
/*
AizuOnline A0544
Title Sugoroku
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int N,M;
int masu[1000];
int sai[1000];
//
main()
{
  int i,pos,kai;

  while(EOF != scanf("%d %d",&N,&M) && (N || M))
    {
      for(i=0;i<N;i++)
	scanf("%d",&(masu[i]));

      for(i=0;i<M;i++)
	scanf("%d",&(sai[i])); 

      pos=0;kai=0;

      while(pos < N && kai < M)
	{
	  pos += sai[kai];
	  kai++;
	  if(masu[pos])
	    pos += masu[pos];
	}

      printf("%d\n",kai);
    }

return(0);
}

Measured memory_bytes: 608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(void){
    string T;
    cin >> T;
    for(int i=0; i<T.size(); ++i){
        if(T[i]=='?') cout << 'D';
        else cout << T[i];
    }
    cout << endl;
    return 0;
}


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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;

class ECrestedIbisVsMonster {
public:
	void solve(std::istream& cin, std::ostream& cout) {
		int h,n;cin >> h >> n;
		vector<pair<int,int>> a(n);
		for (int i = 0; i < n; ++i)
		{
			cin >> a[i].first >> a[i].second;
		}
		vector<ll> dp(30000,INT_MAX);
		dp[0] = 0;
		for(int p = 0;p <= h + 10000;p++){
			for(int i = 0;i < n;i++){
				if(p - a[i].first >= 0)dp[p] = min(dp[p],dp[p-a[i].first] + a[i].second);
			}
		}
//		for(int i = 0;i <= 20;i++)cout << dp[i] << endl;
		ll ans = INT_MAX;
		for(int i = h;i < 30000;i++)ans = min(ans,dp[i]);
		cout <<ans << endl;
	}
};


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


Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef pair<ll,P> T;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll n;
int m,q;
int a[100100];
int c[1400100];
void dfs(int x,int M){
	c[x]=0;
	if(x%7!=0){
		if(a[(x-1)%m]==0&&c[x-1]==-1)dfs(x-1,M);
	}
	if(x%7!=6){
		if(a[(x+1)%m]==0&&c[x+1]==-1)dfs(x+1,M);
	}
	if(x-7>=0){
		if(a[(x-7)%m]==0&&c[x-7]==-1)dfs(x-7,M);
	}
	if(x+7<M){
		if(a[(x+7)%m]==0&&c[x+7]==-1)dfs(x+7,M);
	}
}
ll cnt(int M){
	ll res=0ll;
	for(int i=0;i<M;i++)c[i]=-1;
	for(int i=0;i<M;i++){
		if(a[i%m])continue;
		if(c[i]==-1){
			dfs(i,M);
			res++;
		}
	}
	return res;
}
int main(){
	scanf("%lld %d %d",&n,&m,&q);
	for(int i=0;i<q;i++){
		int tmp;
		scanf("%d",&tmp);
		a[tmp]=1;
	}
	int M = m;
	if(m%7!=0)M*=7;
	ll l = 7ll*n/M;
	ll A = cnt(M);
	ll B = cnt(2*M);
	cout << A+(B-A)*(l-1ll) << endl;

	return 0;
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  while(1){
    int a,b; cin>>a>>b;
    if(a==0 && b==0) break;
    rep(i,0,a){
      rep(i,0,b){
        cout<<"#";
      }
      co("");
    }
    co("");
  }
    
  return 0;
}


Measured memory_bytes: 3084
#include <stdio.h>

int main(void)
{
    long long int N, K_tmp=1;
    int i=0,K;

    scanf("%lld %d",&N, &K);

    if(K_tmp > N){
        i=1;
    }
    while(K_tmp <= N){
        K_tmp *= K;
        i++;
    } 

    printf("%d\n",i);
    

    return 0;
}

Measured memory_bytes: 128
import           Control.Monad
import           Data.Vector.Unboxed ((!))
import qualified Data.Vector.Unboxed as V

main = do
  [_, q] <- map read.words <$> getLine
  s <- getLine
  let memo = V.fromList $ f (0::Int) s
      f n []           = [n]
      f n ('A':'C':cs) = n:n:f (n+1) cs
      f n (c:cs)       = n:f n cs
      solve 0 = return ()
      solve q = do
        [l, r] <- map read.words <$> getLine
        print (memo!r - memo!l)
        solve (q-1)
  solve q


Measured memory_bytes: 10844
#include<iostream>

using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  int x = M / N; //答えはx以下の整数
  int i;
  for(i=x;i>=1;i--)
    if(M%i==0){
      cout << i << endl;
      break;
    }
}

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

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

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

int prs[10000];
int pri=1;

int isPrime(int a){
  int flg;
  if (sqrt(a)>prs[pri]){
    for (int i=prs[pri]+2;i<=sqrt(a);i+=2){
      flg=1;
      for (int j=0;j<=pri;j++){
	if (sqrt(i)<prs[i])break;
	if (i%prs[j]==0){
	  flg=0;
	  break;
	}
      }
      if (flg)prs[++pri]=i;
    }
    //for (int i=0;i<=pri;i++)cout << prs[i] << " ";
  }
  for (int i=0;i<=pri;i++){
    if (sqrt(a)<prs[i])break;
    if (a%prs[i]==0)return 0;
  }
  return 1;
}

int main(){
  prs[0]=2;
  prs[1]=3;
  
  int n,a,cnt=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    cnt += isPrime(a);
  }
  cout << cnt<<endl;
  return 0;
}

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

#define MAX_N 1000

struct CALORIE_TABLE {

	int  i;
	int  p;
	int  q;
	int  r;
	int  c;
	bool outFlg;

};

int main()
{

	int n, P, Q, R, C, cnt;
	CALORIE_TABLE cal[MAX_N];

	while( cin >> n, n ) {

		cnt = 0;

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

			cin >> cal[i].i >> cal[i].p >> cal[i].q >> cal[i].r;

			cal[i].c = ( cal[i].p + cal[i].r ) * 4 + cal[i].q * 9;
			cal[i].outFlg = false;

		}

		cin >> P >> Q >> R >> C;

		for( int i = 0; i < n; i++ ) {
			if( cal[i].p > P || cal[i].q > Q || cal[i].r > R || cal[i].c > C ) { cal[i].outFlg = true; cnt++; }
		}

		if( cnt != n ) {
			for( int i = 0; i < n; i++ ) {
				if( !cal[i].outFlg ) cout << cal[i].i << endl;
			}
		}
		else cout << "NA" << endl;

	}

	return 0;

}

Measured memory_bytes: 1188
n,m=map(int,input().split())
sw=[[] for _ in range(m)]
for _ in range(m):
    temp=list(map(int,input().split()))
    sw[_]=temp[1:]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    temp=[0]*n
    for j in range(n):
        if i&1: temp[j]=1
        i>>=1
    flag=1
    for l,s in enumerate(sw):
        cnt=0
        for k in s:
            if temp[k-1]==1: cnt+=1
        if p[l]!=cnt%2:
            flag=0
            break
    if flag: ans+=1
print(ans)

Measured memory_bytes: 9168
#include <iostream>
using namespace std;
int main() {
  int h, w;
  bool s[52][52] = {};
  cin >> h >> w;
  for (int i = 1; i <= h; i++) {
    string str;
    cin >> str;
    for (int j = 1; j <= w; j++) {
      if (str[j - 1] == '#') {
        s[i][j] = true;
      } else {
        s[i][j] = false;
      }
    }
  }
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (s[i][j]) {
        if (!(s[i - 1][j] || s[i + 1][j] || s[i][j - 1] || s[i][j + 1])) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
class SegTree:
    def __init__(self, segfunc, e, v, init_val = None):
        """
        segfunc: function 区間にしたい操作\n
        e: Any 単位元\n
        v: int or List 要素数か格納する配列\n
        init_val: Any 初期値
        """
        self.segfunc = segfunc
        self.e = e
        self.init_val = init_val if init_val != None else e
        if isinstance(v, int):
            v = [self.init_val] * v
        self.n = len(v)
        self.log = (self.n).bit_length()
        self.size = 1 << self.log
        self.tree = [e] * 2 * self.size
        # 1-indexedなのでtree[1:self.size]がN-1要素
        # tree[self.size:self.size + N]が配列
        for i in range(self.n):
            self.tree[self.size + i] = v[i]
        for i in range(self.size - 1, 0, -1):
            self._update(i)

    def set(self, k, x) -> None:
        """
        k番目の値をxに更新\n
        k: index(0-indexed)\n
        x: update value
        """
        k += self.size
        self.tree[k] = x
        for i in range(1, self.log + 1):
            self._update(k >> i)

    def get(self, k):
        """
        a[k]を返す\n
        k: index(0-indexed)
        """
        assert 0 <= k < self.size
        return self.tree[k + self.size]

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る\n
        l: index(0-indexed)\n
        r: index(0-indexed)
        """
        res = self.e
        l += self.size
        r += self.size
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

    def all_query(self):
        """
        全範囲にsegfuncしたものを得る
        """
        return self.tree[1]

    # 二分探索実装、いる？

    def _update(self, k):
        self.tree[k] = self.segfunc(self.tree[k * 2], self.tree[k * 2 + 1])

#import
#import math
#import numpy as np
#= int(input())
#= input()
N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]

MAX_A = 300005

dp = SegTree(max, 0, MAX_A, 0)
for i in range(N):
    x = A[i]
    now = dp.query(max(0, x - K), min(x + K + 1, MAX_A)) + 1
    dp.set(x, now)

ans = dp.all_query()
print(ans)


Measured memory_bytes: 120720
# abc164_b.py
# https://atcoder.jp/contests/abc164/tasks/abc164_b

# B - Battle /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 高橋君と青木君がモンスターを闘わせます。
# 高橋君のモンスターは体力が Aで攻撃力が B です。 
# 青木君のモンスターは体力が C で攻撃力が Dです。
# 高橋君→青木君→高橋君→青木君→... の順に攻撃を行います。 
# 攻撃とは、相手のモンスターの体力の値を自分のモンスターの攻撃力のぶんだけ減らすことをいいます。 
# このことをどちらかのモンスターの体力が 0以下になるまで続けたとき、 先に自分のモンスターの体力が 0以下になった方の負け、
# そうでない方の勝ちです。
# 高橋君が勝つなら Yes、負けるなら No を出力してください。

# 制約

#     1≤A,B,C,D≤100
#     入力はすべて整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A B C D

# 出力
# 高橋君が勝つなら Yes、負けるなら No を出力せよ。

# 入力例 1
# 10 9 10 10

# 出力例 1
# No

# はじめに、高橋君の攻撃で青木君のモンスターの体力が 10−9=1になります。
# 次に、青木君の攻撃で高橋君のモンスターの体力が 10−10=0になります。
# 高橋君のモンスターの体力が先に 0以下になったため、高橋君の負けです。

# 入力例 2
# 46 4 40 5

# 出力例 2
# Yes


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    A, B, C, D = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    while True:
        C -= B
        if C <= 0:
            return ['Yes']
        A -= D
        if A <= 0:
            return ['No']


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['10 9 10 10']
        lines_export = ['No']
    if pattern == 2:
        lines_input = ['46 4 40 5']
        lines_export = ['Yes']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  // b * x = a
  int x = a / b;
  if (b * x < a)
    ++x;
  cout << x * c << '\n';   
  return 0;
}

Measured memory_bytes: 3648