akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1<<18|3;
int n,all,a[N],l[N],r[N],id[N];bool vis[N];
void GG(){puts("NO");exit(0);}
bool cmp(int x, int y){return l[x]<l[y];}
priority_queue<Pii,vector<Pii>,greater<Pii> >heap;
int main() {
	read(n);all=(1<<n)-1;
	rep(i,0,all){
		read(a[i]),a[i]--;
		if(a[i]>=0)l[i]=r[i]=a[i];
		else l[i]=0,r[i]=all;
	}
	rep(s,0,all)rep(i,0,n-1)if(!(s>>i&1))umax(l[s^(1<<i)],l[s]+1);
	per(s,all,0)rep(i,0,n-1)if(s>>i&1)umin(r[s^(1<<i)],r[s]-1);
	rep(s,0,all)if(l[s]>r[s])GG();
	rep(s,0,all)id[s]=s;sort(id,id+all+1,cmp);
//	rep(s,0,all)printf("%d:%d %d\n",s,l[s],r[s]);
	for(int s=0,p=-1;s<=all;s++){
		while(p+1<=all&&l[id[p+1]]<=s)p++,heap.push(Pii(r[id[p]],id[p]));
	//	while(!heap.empty()&&vis[heap.top().se])heap.pop();
		if(heap.empty())GG();int u=heap.top().se;heap.pop();
		if(s<l[u]||s>r[u])GG();a[u]=s;//vis[u]=1;
	}
//	rep(s,0,all)printf("%d:%d %d %d\n",s,l[s],r[s],a[s]);
	for(int i=1,j=0;i<=all;i++){
		for(int k=1<<(n-1);!((j^=k)&k);k>>=1);
	//	printf("%d %d\n",i,j);
		if(i<j)swap(a[i],a[j]);
	}
	printf("YES\n");rep(i,0,all)printf("%d ",1+a[i]);
	return 0;
}


Measured memory_bytes: 7792
S = gets.chomp
T = gets.chomp

scount, tcount= Hash.new{[]},Hash.new{[]}

S.length.times do |i|
	scount[S[i]] = scount[S[i]].push(i)
end

T.length.times do |i|
	tcount[T[i]] = tcount[T[i]].push(i)
end

if scount.values == tcount.values
	print("Yes\n")
else
	print("No\n")
end

Measured memory_bytes: 6848
#include <iostream>
#include <cstdio>

long long cnt;

void insertionSort(int *a, int n, int g){
	int i,v,j;
	for(i=g; i<n; i++){
		v = a[i];
		j = i-g;
		while(j>=0 && a[j] > v){
			a[j+g] = a[j];
			j -= g;
			cnt++;
		}
		a[j+g] = v;
	}
}

void shellSort(int *a, int n){
	int *g;
	int i,j,m;
	j=1;
	m=0;
	while(j<=n){
		m++;
		j = 3*j + 1;
	}
	std::printf("%d\n",m);
	g = new int[m];
	g[0]=1;
	for(i=1; i<m; i++){
		g[i] = 3*g[i-1] + 1;
	}
	for(i=m-1; i>0; i--){
		std::printf("%d ", g[i]);
		insertionSort(a, n, g[i]);
	}
	std::printf("%d\n", g[0]);
	insertionSort(a, n, g[0]);
}



int main(){
	int N, i;
	int *a;
	std::scanf("%d", &N);
	a = new int[N];
	
	for (i=0; i<N; i++) std::scanf("%d", &a[i]);
	
	shellSort(a, N);
	
	std::printf("%d\n", cnt);
	for (i=0; i<N; i++) std::printf("%d\n", a[i]);

	return 0;
}

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

int main(void){
	int H, W, K, ans = 0;
	char c;
	std::cin >> H >> W >> K;
	std::vector<std::vector<char>> fig(H, std::vector<char>(W));
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			std::cin >> c;
			fig[i][j] = c;
		}
	}
	
	for(int cow = 0; cow < (1 << H); cow++){
		for(int col = 0; col < (1 << W); col++){
			int cnt = 0;
			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					if(((cow >> i) & 1 == 1) || (((col >> j) & 1 == 1))) continue;
					if(fig[i][j] == '#') cnt++;
				}
			}
			if(cnt == K) ans++;
		}
	}

	std::cout << ans << std::endl;

	return 0;
}


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

using namespace std;

char s[105][105];
int dp[105][105];

int main(void)
{
    int h,w; cin>>h>>w;
    for(int i=1;i<=h;++i) cin>>s[i]+1;
    for(int j=1;j<=w;++j){
        s[0][j] = '0';
        if(s[1][j-1]!='#' && s[1][j]=='#') dp[1][j] = dp[1][j-1]+1;
        else dp[1][j] = dp[1][j-1];
    }
    for(int i=1;i<=h;++i){
        s[i][0] = '0';
        if(s[i-1][1]!='#' && s[i][1]=='#') dp[i][1] = dp[i-1][1]+1;
        else dp[i][1] = dp[i-1][1];
    }
    for(int i=2;i<=h;++i){
        for(int j=2;j<=w;++j){
            int l = dp[i][j-1], u = dp[i-1][j];
            if(s[i][j-1]!='#' && s[i][j]=='#') ++l;
            if(s[i-1][j]!='#' && s[i][j]=='#') ++u;
            dp[i][j] = min(l,u);
        }
    }
    cout<<dp[h][w];
    return 0;
}

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

int main()
{
  string S, T;
  cin >> S >> T;
  bool OK = true;
  for (int i = 0; i < S.size(); i++)
  {
    if (S[i] != T[i])
    {
      OK = false;
      break;
    }
  }
  if (OK) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3572
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 10;

int n, a[N], x;

signed main()
{
	init_ios();	
	cin >> n >> x;
	int res = 0;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	for (int i = n-1; i >= 1; --i) {
		if (a[i]+a[i+1] <= x)
			continue;
		if (a[i] > 0) {
			if (a[i+1] >= x) {
				res += a[i]+a[i+1]-x;
				a[i] = 0;
			}
			else {
				int ile = a[i]+a[i+1]-x;
				a[i] -= ile;
				res += ile;
			}
		}
		else {
			res += a[i+1]-x;
			a[i+1] = x;
		}
	}
	cout<<res<<"\n";
}

Measured memory_bytes: 1152
N,X,M = gets.chomp.split.map(&:to_i)
an = X
ans = 0
s = 0
ss = 0
count = 0
countcount = 0
kokomade = 0
kokomademade = 0
ppp = 0

if X == 1
  puts N
  exit
end

(1..N).each do |i|
  if i == 1
  	anan = an % M
  else
  	anan = (an**2 % M)
    if anan == 0
      puts ans
      exit
    elsif anan == s
      ans += (ans - kokomade) * ((N - i + 1) / (i - count))
      add = ((N - i + 1) % (i - count))
      (1..add).each do |j|
        ans += anan
        ananan = anan**2 % M
        anan = ananan
      end
      puts ans
      exit
    elsif anan == ss
      ans += (ans - kokomademade) * ((N - i + 1) / (i - countcount))
      add = ((N - i + 1) % (i - countcount))
      (1..add).each do |j|
        ans += anan
        ananan = anan**2 % M
        anan = ananan
      end
      puts ans
      exit
    end
  end
  if an**2 > M && ppp == 0
    s = anan
    kokomade = ans
    count = i
    ppp += 1
  end
  if i > 20 && ppp == 1
    ss = anan
    kokomademade = ans
    countcount = i
    ppp += 1
  end
  ans += anan
  an = anan
end

puts ans

Measured memory_bytes: 14416
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll n;
	ll m = 0, a = 0, r = 0, c = 0, h = 0;

	REP(i, n)
	{
		instr s_;
		switch(s_[0])
		{
		case 'M':
			m++;
			break;
		case 'A':
			a++;
			break;
		case 'R':
			r++;
			break;
		case 'C':
			c++;
			break;
		case 'H':
			h++;
			break;
		}
	}

	return OUT(m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h);
}


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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;
	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	lli now=0;
	lli ans = 0;
	for(lli i=n-1;i>=0;i--){
		if(a[i]>=now){
			ans += a[i];
		}
		else if(now-a[i]>=2){
			cout<<-1<<endl;
			return 0;
		}
		now = a[i];
	}
	if(a[0] != 0){
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

bool check(int n){
	bool r[3] = {};
	while(n > 0){
		int a = n % 10;
		n /= 10;
		if(a != 3 and a != 5 and a != 7) return false;
		if(a == 3) r[0] = true;
		if(a == 5) r[1] = true;
		if(a == 7) r[2] = true;
	}
	return r[0] and r[1] and r[2];
}

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

	int ans = 0;
	for(int i = 3; i <= n; i++){
		for(int j = 1e9; j > 0; j /= 10){
			if(i >= j and  i / j % 2 == 0){
				i += j - 1;
				break;
			}
		}

		if(check(i)) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

int min,max,many=0;
int change,hoge,var;

scanf("%d",&min);
scanf("%d",&max);

for(;min<=max;min++){
hoge=0;
var=min;
hoge+=var/10000;
var%=10000;
hoge+=10*(var/1000);
var%=1000;
hoge+=100*(var/100);
var%=100;
hoge+=1000*(var/10);
var%=10;
hoge+=10000*(var);

if(min ==hoge)many++;
}
printf("%d",many);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


#define MAX_V 2010

struct edge { int to; long long cost; };
int V;

vector<edge> tree[MAX_V];
ll d[MAX_V];
int N;

// s: 開始地点の頂点
void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + N, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) { continue; }
        for (int i = 0; i < tree[v].size(); i++) {
            edge e = tree[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}


int main(){
    cin >> N;
    int x, y;
    cin >> x >> y;
    x--, y--;

    rep(i, N) {
        tree[i].push_back({i+1,1});
        tree[i+1].push_back({i,1});
    }
    tree[x].push_back({y,1});
    tree[y].push_back({x,1});

    ll ans[2010] = {};
    rep(i, N){
        memset(d, 0, sizeof(d));
        dijkstra(i);
        rep(j, N) ans[d[j]]++;
    }

    rep(i, N-1) cout << ans[i+1] / 2 << endl; 

    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		string S = GetString();

		bool[] isIgnore = new bool[N];
		bool isUpdated = true;
		while(isUpdated)
		{
			isUpdated = false;
			int iLeft = -1;
			for(int i = 0; i < N; i++)
			{
				if(isIgnore[i])
					continue;
				
				if(S[i] == '(')
				{
					iLeft = i;
					continue;
				}

				if(iLeft != -1)
				{
					isIgnore[iLeft] = true;
					isIgnore[i] = true;
					iLeft = -1;
					isUpdated = true;
				}
			}
		}

		int numAddLeft = 0;
		int numAddRight = 0;
		for(int i = 0; i < N; i++)
		{
			if(isIgnore[i])
				continue;
			if(S[i] == ')')
			{
				numAddLeft++;
			}
			else
			{
				numAddRight++;
			}
		}

		StringBuilder ans = new StringBuilder();
		for(int i = 0; i < numAddLeft; i++)
			ans.Append('(');
		ans.Append(S);
		for(int i = 0; i < numAddRight; i++)
			ans.Append(')');
		Console.WriteLine(ans);		
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11092
/*
  AtCoder Regular Contest 098
  C - Attention
*/

#include<iostream>
using namespace std;

int N;
char S[300001];

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

  int mincost, cost = 0;
  for (int i = 1; i < N; ++i) if (S[i] == 'E') ++cost;
  
  mincost = cost;
  for (int i = 1; i < N; ++i) {
    if (S[i-1] == 'W') ++cost;
    if (S[i] == 'E') --cost;
    if (cost < mincost) mincost = cost;
  }
  
  printf("%d\n", mincost);
  return 0;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"flag"
	"fmt"
	"os"
	"sort"
	"strconv"
	"testing"
)

/*-----------Main-----------*/

func main() {
	x, n := readI(), readI()
	p := readIs(n)
	dis := 100
	ans := 0
	for i := 0; i <= 101; i++ {
		if isThere(p, i) {
			continue
		}
		if abs(i-x) < dis {
			dis = abs(i - x)
			ans = i
		}
	}
	fmt.Println(ans)
}

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

func isThere(a []int, b int) bool {
	for _, v := range a {
		if v == b {
			return true
		}
	}
	return false
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	testing.Init()
	if flag.Parse(); flag.Arg(0) == "debug" {
		debug()
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Println("Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 1856
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }

int main()
{
    optimize_cin();
    int N; cin >> N;
    vector<int> p;
    p.resize(N);
    rep (i, N) { cin >> p[i]; }

    sort(ALL(p));

    p[SZ(p) - 1] /= 2;

    int sum = 0;
    rep (i, SZ(p))
    {
        sum += p[i];
    }
    
    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
maxl = max(L)
minr = min(R)
ans = minr-maxl + 1
if ans < 0:
    ans = 0
print(ans)

Measured memory_bytes: 11016
import sys

input=sys.stdin.readline

N,M=map(int,input().split())
P=[0 for i in range(0,M)]
Y=[0 for i in range(0,M)]
for i in range(0,M):
    P[i],Y[i]=map(int,input().split())

data=[[] for i in range(0,N)]
ans=[0 for i in range(0,M)]
for i in range(0,M):
    data[P[i]-1].append([Y[i],i])
for i in range(0,N):
    data[i].sort()

for i in range(0,N):
    if data[i]!=[]:
        for j in range(0,len(data[i])):
            p=i+1
            x=j+1
            pp=''
            xx=''
            while 6-len(str(p))>len(pp):
                pp+='0'
            while 6-len(str(x))>len(xx):
                xx+='0'
            ans[data[i][j][1]]=pp+str(p)+xx+str(x)
for i in range(0,M):
    print(ans[i])

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,ans = 0;
  rep(i,5){
    cin >> a;
    a = (a < 40)? 40 : a;
    ans += a;
  }
  cout << ans / 5<<endl;
  return 0;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	bool isA = false;

	if (s.at(0) == 'A') { isA = true; }

	bool isC = false;
	int count = 0;
	bool isUpper = false;
	for (int i = 2; i < s.size() - 1; i++)
	{
		
		if (isupper(s.at(i)))
		{
			if (s.at(i) == 'C')
			{
				count++;
				if (count == 1)
				{
					isC = true;
				}
				else
				{
					isUpper = true;
					break;
				}
			}
			else
			{
				isUpper = true;
				break;
			}
		}
	}
	if (isupper(s.at(1)) || isupper((s.at(s.size() - 1))))
	{
		isUpper = true;
	}

	if (isA && isC && !isUpper)
	{
		cout << "AC" << endl;
	}
	else
	{
		cout << "WA" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    int B[N];
    vi ans;
    per(i,N){
        int cnt=0;
        int pos=2*(i+1);
        while(N>=pos){
            cnt+=B[pos-1];
            pos+=i+1;
        }
        cnt%=2;
        B[i]=cnt^A[i];
        if(cnt^A[i]) ans.eb(i+1);
    }
    cout << ans.size() << endl;
    for(auto a:ans){
        cout << a << " ";
    }
    cout << endl;

}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,m;
  cin >> n >> m;
  vl rui(n,0);
  REP(i,m){
    ll l,r;
    cin >> l >> r;
    l--;
    rui[l]++;
    if(r<n)rui[r]--;
  }
  ll ans = 0;
  REP(i,n){
    if(i!=0) rui[i] += rui[i-1];
    if(rui[i]==m) ans ++;
    //cout << rui[i] << endl;
  }
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;


int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	for(int i = 0;i < s.length();i++){
		printf("%c",(s[i] - 'A' + n) % 26 + 'A');
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define gcd __gcd
#define pcount __builtin_popcount
#define pcountll __builtin_popcountll
#define nxtperm next_permutation
//primitive roots: 998244353 - 3; 7340033 - 5
//#pragma 03
//#pragma GCC target ("sse4.2")

const ll mod = 1000000007;		const double PI = acos(-1.);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef complex<double> cd;

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
	{
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const
	{
        static const uint64_t kawaii = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + kawaii);
    }
};

const int maxn = 2e5 + 100; 
int n, a[maxn], dp[maxn][5]; // l__0__Start__1__End__2__R
int ans = 1e9; 

signed main()
{
//	freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
// 	fast_cin();
	cin >> n; 
	for(int i=1;i<=n;i++) cin >> a[i];
	for(int i=1;i<=n;i++) for(int j=0;j<=4;j++) dp[i][j] = 1e9; 
	for(int i=1;i<=n;i++) 
	{
		for(int j=0;j<5;j++) 
		{
			for(int k=0;k<5;k++) 
			{
				if(k > j) continue; 
				if(k == 0) dp[i][j] = min(dp[i][j], dp[i-1][0] + a[i]);
				if(k == 1) dp[i][j] = min(dp[i][j], dp[i-1][1] + (!a[i] ? 2 : (a[i] % 2))); 
				if(k == 2) dp[i][j] = min(dp[i][j], dp[i-1][2] + (a[i] + 1) % 2); 
				if(k == 3) dp[i][j] = min(dp[i][j], dp[i-1][3] + (!a[i] ? 2 : (a[i] % 2))); 
				if(k == 4) dp[i][j] = min(dp[i][j], dp[i-1][4] + a[i]);  
			}
		}; 
	}
	int ans = 1e9; 
	for(int i=0;i<5;i++) ans = min(ans, dp[n][i]); 
	cout << ans; 
}

/*
Test input:
*/


Measured memory_bytes: 4992
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1e5+10;
vector<int> vs[2*L];
int a[L];
LL r[L];
int main() {
	int n,m;
	scanf("%d%d%d", &n,&m,a);
	LL sum=0;
	for(int i=1;i<n;i++){
		scanf("%d",a+i);
		int b=a[i];
		if(b<a[i-1]){
			b+=m;
		}
		sum+=b-a[i-1];
		if(b-a[i-1]>1){
			vs[b].push_back(a[i-1]+1);
		}
	}
	priority_queue<int> pq;
	LL v=0;
	for(int i=2*m-1;i>=0;i--){
		while(pq.size()&&pq.top()>=i){
			pq.pop();
		}
		for(int j:vs[i]){
			v+=i-j;
			pq.push(j);
		}
		r[i%m]+=v;
		v-=pq.size();
	}
	LL w=0;
	for(int i=0;i<m;i++){
		w=max(w,r[i]);
	}
	printf("%lld\n",sum-w);

	return 0;
}



Measured memory_bytes: 8952
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<int,int>
#define iil pair<ll,ll>
#define se second
#define ld long double
#define mod 1000000007
#define popcount __builtin_popcountll
#define x0 zxcxzcsacasd
#define x1 ghfghujfgfg
#define y0 olkjhdnncvcv
#define y1 bhvgrewm345345435
#define debug(x) std::cerr<<#x<<": "<<(x)<<'\n'
#define all(x) x.begin(), x.end()
using namespace std;
void test_case(){
	
}
int main(){
	ll n, x, m;
	cin>>n>>x>>m;
	ll ans = x;
	map<int, int>id;
	vector<int>v;
	v.pb(x);
	ll rem = n - 1;
	for(int i=1;i<n;i++){
		ll a = v[i-1];
		id[a] = i - 1;
		a*=a;
		a = a%m;
		if(id.count(a)){
			int len = 0;
			ll sum = 0;
			int l = v.size();
			for(int j = id[a];j<l;j++){
				sum+=v[j];
				len++;
			}
			ll c = rem / len;
			ans+=c * sum;
			rem%=len;
			for(int j = id[a];rem;j++, rem--){
				ans+=v[j];
			}
			break;
		}
		rem--;
		ans+=a;
		v.pb(a);
	}
	cout<<ans<<endl;
}


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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	ll n;
	cin>>n;
	string res="";
	while(n>0){
		n--;
		res=char(n%26+97)+res;
		n/=26;
	}
	cout<<res;
}

Measured memory_bytes: 3620
// aising 2019 E Attack to a Tree
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

#define pb push_back

typedef long long LL;

const int MAXN = 5010;

int N, A[MAXN], sz[MAXN];
LL DP[MAXN][MAXN][2], INVALID;
std::vector<int> G[MAXN];

inline void upd_min(LL & x, LL y) { y < x ? x = y : 0; }
void dfs(int, int);

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", A + i);
	for (int i = 1, ui, vi; i < N; i++) {
		scanf("%d%d", &ui, &vi);
		--ui, --vi;
		G[ui].pb(vi), G[vi].pb(ui);
	}

	memset(DP, 0x3f, sizeof DP);
	INVALID = DP[0][0][0];
	dfs(0, -1);
	for (int i = 0; i < N; i++)
		if (DP[0][i][0] != INVALID || DP[0][i][1] < 0) {
			printf("%d\n", i);
			return 0;
		}

	return 0;
}

void dfs(int u, int fa) {
	sz[u] = 1;
	DP[u][0][A[u] > 0 ? 0 : 1] = A[u];
	/* DP[u][j][0 / 1] - u is root, disconnect j cable(s), 
	 * whether there's a computer in the connected component
	 * 0 - no, 1 - yes
	 */
	LL (*nxt)[2] = DP[5005];
	for (auto v : G[u]) {
		if (v == fa) continue;
		dfs(v, u);

		for (int i = 0; i < MAXN; i++) nxt[i][0] = nxt[i][1] = INVALID;
		for (int i = 0; i < sz[u]; i++)
			for (int j = 0; j < sz[v]; j++) {
				// let v be alone
				if (DP[v][j][0] != INVALID || DP[v][j][1] < 0) {
					upd_min(nxt[i + j + 1][0], DP[u][i][0]);
					upd_min(nxt[i + j + 1][1], DP[u][i][1]);
				}
				for (int su = 0; su <= 1; su++)
					for (int sv = 0; sv <= 1; sv++)
						if (DP[u][i][su] != INVALID && DP[v][j][sv] != INVALID)
							upd_min(nxt[i + j][su | sv], DP[u][i][su] + DP[v][j][sv]);
			}
		for (int i = 0; i < MAXN; i++) {
			DP[u][i][0] = nxt[i][0];
			DP[u][i][1] = nxt[i][1];
		}
		sz[u] += sz[v];
	}
}


Measured memory_bytes: 393344
#include<bits/stdc++.h>
#define ll long long
const ll mod=1e9+7;
using namespace std;
ll d[45][1<<17];
ll n,x,y,z;
int main()
{
    scanf("%lld%lld%lld%lld",&n,&x,&y,&z);
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=1ll*ans*10;
        ans%=mod;
    }
    ll s=(1<<x+y+z)-1;
    ll u=(1<<x-1)|(1<<x+y-1)|(1<<x+y+z-1);
    d[0][0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=s;j++)
        {
            for(ll k=1;k<=10;k++)
            {
                ll t=(j<<k)|(1<<k-1);
                t&=s;
                if((t&u)!=u)
                {
                    d[i][t]=(d[i][t]+d[i-1][j])%mod;
                }
            }
        }
    }
    for(ll i=0;i<=s;i++)
    {
        ans=(ans-d[n][i]+mod)%mod;
    }
    cout<<ans%mod<<endl;
}


Measured memory_bytes: 42240
from math import floor
from queue import LifoQueue


def print_sol(c, sol):
    print('Case #{}: {}'.format(c, sol))


def rd_int():
    return int(input())


def rd_str():
    return input()


def rd_str_lst():
    return input().split(' ')


def sp_str_lst():
    return list(input())


def rd_int_lst():
    return [int(i) for i in rd_str_lst()]


def sp_int_lst():
    return [int(i) for i in sp_str_lst()]


def dfs(g, i, v):
    """
    recursive post order dfs
    Args:
        g: array of graph nodes
        i: node to traverse
        v: visited array

    Returns: a post order dfs of graph g
    """
    v[i] = True
    for j in g[i]:
        if not v[j]:
            dfs(g, j, v)

    print(i)


def dfs_iter(g, i, n):
    v = [False] * n
    stack = LifoQueue()
    stack.put(i)
    while stack.not_empty:
        u = stack.get()
        v[u] = True
        print(u)
        for i in g[u]:
            if not v[i]:
                stack.put(i)


def main():
    n = rd_int()

    sol = 0
    for i in range(1, n + 1):
        ap_len = floor(n / i)
        ap_sum = (ap_len / 2) * (2 * i + (ap_len - 1) * i)
        sol += ap_sum

    print(int(sol))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9636
import java.util.Scanner
import java.util.ArrayList

fun main(args: Array<String>){
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()

    var arraylist = ArrayList<Int>()
    for(i in 0 until N){
       arraylist.add(sc.nextInt())
    }

    var mani_flag = false
    var mani_index : Int
    var imp_flag = false
    for(i in 0 until N-1){
       if(arraylist.elementAt(i) > arraylist.elementAt(i+1)){
           if(mani_flag){
               imp_flag = true
               break
           }else{
               var nowmin = arraylist.elementAt(i+1)
               mani_index = i+1
                for(j in i+2 until N){
                    if(arraylist.elementAt(j) < nowmin){
                        nowmin = arraylist.elementAt(j)
                        mani_index = j
                    }
                }
               val tmp = arraylist.elementAt(i)
               arraylist.removeAt(i)
               arraylist.add(i, nowmin)
               arraylist.removeAt(mani_index)
               arraylist.add(mani_index, tmp)
               mani_flag = true
           }
       }
    }
    for(i in 0 until N - 1){
        if(arraylist.elementAt(i) > arraylist.elementAt(i+1)){
            imp_flag = true
        }
    }
    if(imp_flag){
        println("NO")
    }else{
        println("YES")
    }
}

Measured memory_bytes: 31392
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,t;
  cin >> n >> t;
  vector<pair<int,int>>ab;
  rep(i,n){
    int A,B;
    cin >> A >> B;
    ab.push_back(make_pair(A,B));
  }
  sort(ab.begin(),ab.end());
  
  ll dp[3030][3030]={};
  ll ans = 0;
  rep(i,n){
    rep(j,t){
      dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
      if(j+ab[i].first<t)dp[i+1][j+ab[i].first]=max(dp[i+1][j+ab[i].first],dp[i][j]+ab[i].second);
    }
    ans=max(ans,dp[i][t-1]+ab[i].second);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 75436
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int r=sc.nextInt();
    if (n>=10) {
      System.out.println(r);
    }else{
      System.out.println(100*(10-n)+r);
    }
  }
}


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

int main(){
	ll n;
	cin >> n;
	ll arr[85];
	for(ll i=0;i<n;i++){
		cin >> arr[i];
	}
	ll uang=1000;
	for(ll i=0;i<n;i++){
		if(i==0) continue;
		else if(arr[i]>arr[i-1]){
			uang=floor((double)uang/arr[i-1])*arr[i]+(uang%arr[i-1]);
		}
	}
	cout << uang << '\n';
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	cout << "AB";
	if(n/1000)
		cout << "D";
	else
		cout << "C";

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k,s = LI()

if s == 10**9:
    a = [s]*k + [s-1]*(n-k)
else:
    a = [s]*k + [10**9]*(n-k)
print(*a)

Measured memory_bytes: 46276
s = input()

if((int)(s[0:2]) <= 12 and (int)(s[0:2]) >= 1) :
    if(int(s[2:]) <=12 and (int)(s[2:]) >=1):
        print("AMBIGUOUS")
    elif(int(s[2:]) <= 99 and (int)(s[2:]) >= 0):
        print("MMYY")
    else:
        print("NA")
elif ((int)(s[0:2]) <= 99 and (int)(s[0:2]) >= 0):
     if((int)(s[2:]) <=12 and (int)(s[2:]) >=1):
         print("YYMM")
     else:
         print("NA")
else:
    print("NA")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,c[3]={0,0,0};
    cin >> n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    ll sum=1;
    for(ll i=0;i<n;i++){
        ll cnt=0,id=-1;
        if(a[i]==c[0]){
            cnt++;
            id=0;
        }
        if(a[i]==c[1]){
            cnt++;
            id=1;
        }
        if(a[i]==c[2]){
            cnt++;
            id=2;
        }
        if(id==-1){
            cout << 0 << endl;
            return 0;
        }
        sum*=cnt;
        c[id]++;
        sum%=MOD;
    }
    cout << sum << endl;
}

Measured memory_bytes: 4048
#-*- coding:utf-8 -*-
import math
a = list(map(int,input().split()))

s = 0
if a[1] < 10:
    s = 10*a[0]+a[1]
elif a[1] < 100:
	s = 100*a[0]+a[1]
else: s = 1000*a[0]+a[1]

n = math.floor(math.sqrt(s))
j = 0
for i in range(n):
	if (i+1)**2 == s:
		print("Yes")
		j = 1
if j == 0:
	 print("No")

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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rept(i, a, b) for(int i=a ; i<=b; i++)
    
int main(){
    int r, d, x;
    cin >> r >> d >> x;
    rept(i, 1, 10){
        x = r*x - d;
        cout << x << endl;
    }
}

                
    

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

using namespace std;

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

  int count = 0;
  for(int i = 0; i < 6; i++) {
    if(s[i] == '1') {
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long i64;
typedef int *pint;
const int MAXN = 100 + 20;
 
int a[MAXN], b[MAXN];
int p1, p2;
int M = 100;
i64 N;
 
int main()
{
	p1 = 0, p2 = 0;
	cin >> N, N++;
 
	while (N > 1)
	{
		if (N & 1)
			a[++p1] = M, M--, N--;
		else
			b[++p2] = M, M--, N >>= 1;
	}
 
	cout << ((p1 + p2) << 1) << endl;
 
	for (int i = 1; i <= p1; i++)
		cout << a[i] << " ";
	for (int i = p2; i >= 1; i--)
		cout << b[i] << " ";
	for (int i = 100 - p1 - p2 + 1; i <= 100; i++)
		cout << i << " ";
	cout << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x3f
#define INF 0x3f3f3f3f
#define fi first
#define se second 
#define mp make_pair
#define pa pair<int,int>

using namespace std;

inline ll read()
{
	ll sum=0,f=1;char c=getchar();
	while (!isdigit(c)) {if (c=='-') f=-1;c=getchar();}
	while (isdigit(c)) {sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}

int main()
{
	int n=read(),k=read();
	if ((n+1)/2>=k) cout<<"YES";
	else cout<<"NO";
	return 0;
}

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

// 0 rock, 1 paper, 2 scissors

int encode(int a) {
    return "rps"[a];
}

int decode(char c) {
    if (c == 'r') return 0;
    if (c == 'p') return 1;
    if (c == 's') return 2;
    return -1;
}

const int N = (int)1e5;

char s[N+5];
int dp[N+5][3];

int main() {
    int n,k; scanf("%d %d", &n, &k);
    int pts[3]; scanf("%d %d %d", &pts[0], &pts[2], &pts[1]);
    scanf("%s", s);

    for (int i=0; i<k; i++) {
        int opp = decode(s[i]);
        int use = (opp + 1) % 3;

        dp[i][0] = dp[i][1] = dp[i][2] = 0;
        dp[i][use] += pts[use];
    }
    for (int i=k; i<n; i++) {
        int opp = decode(s[i]);
        int use = (opp + 1) % 3;

        dp[i][0] = max(dp[i-k][1], dp[i-k][2]);
        dp[i][1] = max(dp[i-k][0], dp[i-k][2]);
        dp[i][2] = max(dp[i-k][0], dp[i-k][1]);
        dp[i][use] += pts[use];
    }

    int res = 0;
    for (int i=n-k; i<n; i++) res += max(dp[i][0], max(dp[i][1], dp[i][2]));

    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 1536
# https://atcoder.jp/contests/abc107/tasks/abc107_b


def check(m, p):
    for i in range(len(m)):
        if m[i][p] == "#":
            return(False)
    return(True)


h, w = [int(x) for x in input().split()]
a = []
b = []
for i in range(h):
    a.append(input())
for i in a:
    if i.count("#") != 0:
        b.append(i)
r = []
for i in range(w):
    if check(b, i):
        r.append(i)
for i in range(len(b)):
    tmp = list(b[i])
    for p in r:
        tmp[p] = "*"
    print("".join(tmp).replace("*", ""))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;

int main(){

  int n;
  cin>>n;
  bool p = false;
  bool w = false;
  bool g = false;
  bool y = false;

  for(int i = 0;i<n;i++){
    string s;
    cin>>s;
    if(s == "P"){
      p = true;
    }else if(s == "W"){
      w = true;
    }else if(s == "G"){
      g = true;
    }else{
      y = true;
    }

  }
  if(y){
    cout<<"Four"<<endl;
  }else{
    cout<<"Three"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int n;cin>>n;
	n %= 10;
	if (n == 3){
		cout << "bon" << endl;
	}
	else if (n == 0 || n == 1 || n == 6 || n == 8){
		cout << "pon" << endl;
	}
	else{
		cout << "hon" << endl;
	}
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define test int t; cin>>t; while (t--)
#define ll long long int
#define fellow_junior  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
   fellow_junior

   ll a,c,d;
   cin>>a;
   if(a%1000==0) cout<<0<<endl;
   else cout<<1000-a%1000<<endl;

   return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<cctype>
#include<cmath>
#include<vector>
#include<climits>
#include<queue>

using namespace std;


int main()
{
    int i,ans,mask,d,g;
    int p[11],c[11];
    scanf("%d%d",&d,&g);
    for(i=0; i<d; ++i)
        scanf("%d%d",&p[i],&c[i]);
    ans=1e9;
    for(mask=0; mask < pow(2,d); ++mask)
    //for(mask=0; mask < (1 << d); ++mask)
    {
        int s=0,num=0,rest_max=-1;
        for(i=0; i<d; ++i)
        {
            //if((mask/pow(2,i))==1)
            if(mask >> i &1)
            {
                s+=100*(i+1)*p[i]+c[i];
                num+=p[i];
            }
            else
            {
                rest_max=i;
            }
        }
        if(s<g)
        {
            int s1=100*(rest_max+1);
            int need=(g-s+s1-1)/s1;
            if(need>=p[rest_max])
                continue;
            num+=need;
        }
        ans=min(ans,num);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define Max 500000
vector<int> prim;
vector<bool> res(Max+1,true);
void aris(int n){
res[0]=res[1]=false;
	for(int i=2;i<=n;i++){
		if(res[i]){
			prim.push_back(i);
			int k=2;
			while(i*k<=n){
			res[i*k]=false;
			k++;
			}
		}
	}
	return ;
}

int main(){
int n,p;

aris(Max);
while(1){
	cin>>n>>p;
	if(n==-1)break;
	vector<int> tmp,ans;
auto now =upper_bound(prim.begin(),prim.end(),n);
for(int i=0;i<=p;i++){
tmp.push_back(*now);
	for(int j=0;j<=i;j++)ans.push_back(tmp[i]+tmp[j]);
now++;
//if(ans.size()>p)break;
}
sort(ans.begin(),ans.end());
cout<<ans[p-1]<<endl;

		}
return 0;
}



Measured memory_bytes: 3268
import scala.io.{StdIn => in}

object Main extends App {
  val mod = 2019L
  val Array(l, r) = in.readLine.split(" ").map(_.toLong)

  var res = Int.MaxValue + 1L
  for{
    i <- 0L until mod
    if l + i < r
    j <- (i + 1L) until (i + 1L + mod)
    if l + j <= r
  } {
    val v = ((l+i) % mod) * ((l+j) % mod) % mod
    if(res > v) res = v
  }

  val ans = res
  println(ans)
}

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

int main()
{
	int A, B, C, X;
	int cnt = 0;
	cin >> A >> B >> C >> X;
	for ( int a = 0; a <= A; a++ ) {
		for ( int b = 0; b <= B; b++ ) {
			for ( int c = 0; c <= C; c++ ) {
				if ( 500 * a + 100 * b + 50 * c == X ) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
	return ( 0 );
}


Measured memory_bytes: 256
N,K = map(int,input().split())
move = [tuple(map(int,input().split())) for i in range(K)]
mod = 998244353

dp = [0 for i in range(N)]
imos = [0 for i in range(N)]
imos[0] = 1
dp[0] = 1

for i in range(1,N):
    for l,r in move:
        L = i-r
        R = i-l
        if R<0:
            continue
        L = max(L,0)
        if L>=1:
            dp[i] += imos[R]- imos[L-1]
        else:
            dp[i] += imos[R]
        dp[i] %= mod
    imos[i] = dp[i] + imos[i-1]
    imos[i] %= mod

print(dp[N-1])


Measured memory_bytes: 94336
from numpy import argmax, argmin
N = int(input())
a = list(map(int,input().split()))

a_max = max(a)
a_argmax = argmax(a)
a_min = min(a)
a_argmin = argmin(a);

ans = ''
if abs(a_max) >= abs(a_min):
	ans += '{}\n'.format(2 * N - 1)
	for i in range(N):
		ans += '{} {}\n'.format(a_argmax + 1, i + 1)
	for i in range(1, N):
		ans += '{} {}\n'.format(i, i + 1)
else:
	ans += '{}\n'.format(2 * N - 1)
	for i in range(N):
		ans += '{} {}\n'.format(a_argmin + 1, i + 1)
	for i in range(N, 1, -1):
		ans += '{} {}\n'.format(i, i - 1)
ans=ans[:-1]

print(ans)

Measured memory_bytes: 21652
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
v_even,v_odd =[[],[]]

for i in range(n//2):
    v_even.append(v[2*i])
    v_odd.append(v[2*i+1])

mc1 = Counter(v_even).most_common()
mc2 = Counter(v_odd).most_common()

k1,v1 = mc1[0]
k2,v2 = mc2[0]

if k1!=k2:
    print(n-v1-v2)
else:
    w1=0
    if len(mc1)>1:
        w1=mc1[1][1]
    w2=0
    if len(mc2)>1:
        w2=mc2[1][1]
    print(n-max(v1+w2,v2+w1))


Measured memory_bytes: 65132
#include <bits/stdc++.h>
using namespace std;
 
long gcd(long a, long b) {
  return b != 0 ? gcd(b, a % b) : a;
}
long lcm(long a, long b) {
  return a * b / gcd(a, b);
}
 
int main() {
  long a,b;
  cin>>a>>b;
  
  cout<<lcm(a,b)<<endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {
	    
	    int N = nextInt();
	    int M = nextInt();

	    out.println(N*(N-1)/2+M*(M-1)/2);

 
	}
 
	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 22100