akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5+5;
const long long MOD = 1e9+7;
long long fact[MAXN];
long long rem;
map<long long,long long> m1;
long long power(long long x, long long y, long long p)
{
    long long res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
long long modInverse(long long n, long long p)
{
    return power(n, p-2, p);
}

// Returns nCr % p using Fermat's little
// theorem.
long long nCrModPFermat(long long n, long long r, long long p)
{
   // Base case
   if (r==0)
      return 1;
    if(r>n){
        return 0;
    }
    // Fill factorial array so that we
    // can find all factorial of r, n
    // and n-r

    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
int main(){
    long long n;
    cin>>n;
    fact[0]= 1;
    for(long long i=1;i<=n+1;i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=MOD;
    }
    for(long long i=1;i<=n+1;i++){
        long long x;
        cin>>x;
        if(m1[x]){
            rem = (n+1)-(i-m1[x]+1);
        }
        m1[x] = i;
    }
   // cout<<nCrModPFermat(rem,7,MOD)<<endl;
    for(long long i=1;i<=n+1;i++){

        cout<<(nCrModPFermat(n+1,i,MOD)-nCrModPFermat(rem,i-1,MOD)+MOD)%MOD<<endl;
    }
}


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

using namespace std;

typedef long long ll;

const int MAX_N = 1e6 + 5;

int n, m;
int a[MAX_N];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> m >> n;
	ll sum = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum > 1ll * m) cout << "-1\n";
	else cout << m - sum << "\n";
	return 0;
}

Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))

ans = [0 for _ in range(n)]
for i in range(n - 1, -1, -1):
    s = 0
    for j in range(i, n, i + 1):
        s += ans[j]
    if s % 2 == a[i]:
        ans[i] = 0
    else:
        ans[i] = 1
print(sum(ans))
print(*[i + 1 for i, j in enumerate(ans) if j == 1])

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin>>n;
  if(n/10==9||n%10==9) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}



Measured memory_bytes: 3616
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC168
{
    /// <summary>
    /// 
    /// </summary>
    static class B
    {
        static void Main(string[] args)
        {
            var k = NextInt();
            var s = Next();

            if (s.Length <= k)
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine(s.Substring(0, k) + "...");
            }
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 27536
#include<stdio.h>

#define N 50

int F[N];

int fib(int);

int main(){
  int n;

  scanf("%d",&n);

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

int fib(int n){
  if(n==0 || n==1)
    return F[n] = 1;
  
  if(F[n]!=0)
    return F[n];

  return F[n] = fib(n-2) + fib(n-1);
}



Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

ll p[301];
ll pas[301][301];
void init() {
	p[0] = 1;
	rep1(i, 300) {
		p[i] = p[i - 1] * i%mod;
	}
	rep(i, 301) {
		rep(j, 301) {
			if (i == 0 || j == 0)pas[i][j] = 1;
			else pas[i][j] = (pas[i - 1][j] + pas[i][j - 1]) % mod;
		}
	}
}
ll dp[301][301];
ll cop[301][301];
int main() {
	init();
	int n, m; cin >> n >> m;
	dp[1][0] = 1;
	rep(i, m) {
		rep(j, n+1) {
			rep(k, n+1) {
				cop[j][k] = 0;
			}
		}
		rep(j, n+1) {
			rep(k, n+1) {
				if (j + k > n)continue;
				(cop[j + k][0] += dp[j][k] * j%mod) %= mod;
				(cop[j][k] += dp[j][k] * k%mod) %= mod;
				if (j + k < n) {
					(cop[j][k + 1] += dp[j][k] * (n - j - k)%mod) %= mod;
				}
			}
		}


		rep(j, n+1) {
			rep(k, n+1) {
				dp[j][k] = cop[j][k];
			}
		}
	}
	cout << dp[n][0] << endl;
	//stop
	return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>
#include <string.h>

int main()
{
char str[105];
scanf("%s" , str);
char ch = ' ';

for (int i = 0; i < strlen(str); i++){
	if(str[i] == ',')
	str[i] = ch;
}
printf("%s" , str);

return 0;
	
}

Measured memory_bytes: 1700
package main

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

var B []int
var P []int

func dfs(N, X int) int {
	if N == 0 {
		if X <= 0 {
			return 0
		}
		return 1
	} else if X <= 1+B[N-1] {
		return dfs(N-1, X-1)
	} else {
		return P[N-1] + 1 + dfs(N-1, X-2-B[N-1])
	}
}

func main() {
	sc := NewScanner()
	N, X := sc.NextInt(), sc.NextInt()
	B = []int{1}
	P = []int{1}

	for i := 0; i < N; i++ {
		B = append(B, B[i]*2+3)
		P = append(P, P[i]*2+1)
	}
	fmt.Println(dfs(N, X))

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int n;
string str;

int main(){
	cin >> n;
	cin.ignore();
	rep(i,n){
		getline(cin,str);
		if(str.size() < 7){
			cout << str << endl;
			continue;
		}
		rep(j,str.size()-6){
			if(str[j]=='H'&&str[j+1]=='o'&&str[j+2]=='s'&&str[j+3]=='h'&&str[j+4]=='i'&&str[j+5]=='n'&&str[j+6]=='o'){
				str[j+6]='a';
			}
		}
		cout << str << endl;
	}
}

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

int main(){
	int n,a[300005];
	long long sum=0;
	cin>>n;
	for (int x=1; x<=3*n; x++) cin>>a[x];
	sort (a+1,a+1+(n*3));
	for (int x=1; x<=n; x++){
		sum+=a[3*n-(x*2-1)];
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
ll dp[5001][5000];
int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;

  for(int i = 1;i <= N - 1;i++){
    for(int j = i + 1;j <= N;j++){
      if(s[i-1] == s[j-1])dp[i][j] = min(dp[i-1][j-1] + 1,(ll)j-i);
    }
  }

  ll ans = 0;
  for(int i = 1;i <= N - 1;i++){
    for(int j = i+1;j <= N;j++){
      ans = max(ans,dp[i][j]);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 194816
n,m= map(int,input().split())
a = list(map(int,input().split()))

hwdsum=0
k=0
while k<= m-1:
  hwdsum += a[k]
  k+=1
  
if n-hwdsum>=0:
  print(str(n-hwdsum))
  
else:
  print(str(-1))



Measured memory_bytes: 10052
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;

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

int n,m;
int s[200001];

bool C(int v){
	int cnt=0;
	int now=1;
	for(int i=0;i<m-1;i++){
		if(now+v>s[n-1])return false;
		int l1=lower_bound(s,s+n,now)-s;
		int v1=0,v2=0;
		if(l1<n && now+v>s[l1]){
			v1=max(1,v-abs(now-s[l1]));
		}
		if(l1>0 && now+v>s[l1-1]){
			v2=max(1,v-abs(now-s[l1-1]));
		}
		now+=max(v1,v2);
	}
	return true;
}

bool C2(int v){
	int cnt=0;
	int now=1;
	for(int i=0;i<m-2;i++){
		int l1=lower_bound(s,s+n,now)-s;
		int v1=0,v2=0;
		if(l1<n && now+v>s[l1]){
			v1=max(1,v-abs(now-s[l1]));
		}
		if(l1>0 && now+v>s[l1-1]){
			v2=max(1,v-abs(now-s[l1-1]));
		}
		now+=max(v1,v2);
	}
	return (now+v>s[n-1]);
}


int main(void){
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0)break;
		for(int i=0;i<n;i++){
			scanf("%d",&s[i]);
		}
		if(n==1){
			printf("-1\n");
			continue;
		}
		int l=s[0],r=s[n-1];
		if(C2(l)){
			printf("-1\n");
			continue;
		}
		for(int i=0;i<30;i++){
			int mid=(l+r)/2;
			if(C(mid))l=mid;
			else r=mid;
		}
		printf("%d\n",l);
	}
	return 0;
}

Measured memory_bytes: 3500
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

struct UnionFind {
  std::vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) std::swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

ll N, M;

int main() {
  std::cin >> N >> M;

  UnionFind uf( N+10 );

  rep( i, M ) {
    ll A, B;
    std::cin >> A >> B;
    --A; --B;
    uf.unite( A, B );
  }

  ll ans = 0;

  rep( i, N ) {
    chmax( ans, (ll)uf.size(i) );
  }

  std::cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4044
#include <vector>
#include <iostream>
using namespace std;
typedef long long ll;

struct LazySegmentTree {
	private:
		int n;
		vector<ll> node, lazy;
	public:
		LazySegmentTree(int N) {
			n = 1;
			while(n < N) n <<= 1;
			node.resize(2 * n - 1, 0);
			lazy.resize(2 * n - 1, 0);
		}

		LazySegmentTree(vector<ll> v) {
			int sz = (int) v.size();
			n = 1;
			while(n < sz) n <<= 1;
			node.resize(2 * n - 1);
			lazy.resize(2 * n - 1, 0);

			for(int i = 0; i < sz; i++) node[i + n - 1] = v[i];
			for(int i = n - 2; i >= 0; i--) node[i] = node[i * 2 + 1] + node[i * 2 + 2];
		}

		void eval(int k, int l, int r) {
			if(lazy[k] != 0) {
				//値の伝搬を行う
				node[k] += lazy[k];

				if(r - l > 1) {
					//子ノードへの伝搬を行う
					lazy[2*k+1] += lazy[k] / 2;
					lazy[2*k+2] += lazy[k] / 2;
				}

				lazy[k] = 0;
			}
		}

		//[a, b)に対してxをaddする
		//現在考えているrangeがk, [l,r)となる
		void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
			if(r < 0) r = n;
			eval(k, l, r);

			if(b <= l || r <= a) return;

			if(a <= l && r <= b) {
				lazy[k] += (r - l) * x;
				eval(k, l, r);
			}

			else {
				add(a, b, x, 2*k + 1, l, (l + r) / 2);
				add(a, b, x, 2*k + 2, (l + r) / 2, r);
				node[k] = node[2*k + 1] + node[2*k + 2];
			}

		}

		ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
			if(r < 0) r = n;
			if(b <= l || r <= a) return 0;

			eval(k, l, r);
			if(a <= l && r <= b) return node[k];
			ll vl = getsum(a, b, 2*k + 1, l, (l + r)/2);
			ll vr = getsum(a, b, 2*k + 2, (l + r)/2, r);
			return vl + vr;
		}

		int getmaxrange(int m, int nn) {
			int max = -1;
			int maxlen = 0;
			int len = 0;
			bool connected = true;
			//全ノードを評価する
			for(int i = 0; i < nn; i++) {
				int num = getsum(i, i + 1);
				if(max < num) {
					max = num;
					len = 1;
					maxlen = 1;
					connected = true;
				} else
				if(max == num) {
					if(connected) {
						len++;
						if(len > maxlen) maxlen = len;
					} else {
						len = 1;
						connected = true;
					}
				} else
				if(max > num) {
					len = 0;
					connected = false;
				}

			}
			if(m > max) return 0;
			return maxlen;
		}

		void catnode() {
			int deg = 1;
			for(int i = 0; i < 2 * n - 1; i++) {
				cout << node[i] << " ";
				if(i + 1 == 2 * deg - 1) {
					cout << endl;
					deg *= 2;
				}
			}
			cout << endl;
		}

		void catlazy() {
			int deg = 1;
			for(int i = 0; i < 2 * n - 1; i++) {
				cout << lazy[i] << " ";
				if(i + 1 == 2 * deg - 1) {
					cout << endl;
					deg *= 2;
				}
			}
			cout << endl;
		}
};


int main() {
	int N, M;
	cin >> N >> M;
	LazySegmentTree t(N);
	for(int i = 0; i < M; i++) {
		int L, R;
		cin >> L >> R;
		t.add(L - 1, R, 1);
	}
	cout << t.getmaxrange(M, N) << endl;
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std; typedef long long ll; const int mx=2500;
int main() {
  int n,a; cin>>n>>a; int x[n]; for(int i=0;i<n;i++) cin>>x[i];
  ll dp[n+1][mx+1]; fill(dp[0],dp[n+1],0); dp[0][0]=1;
  for(int i=0;i<n;i++) {
    for(int j=i;j>=0;j--) {
      for(int k=0;k<mx;k++) {
        if (k+x[i]>mx) continue;
        dp[j+1][k+x[i]]+=dp[j][k];
      }
    }
    /*
    for(int i=0;i<=n;i++) {
      for(int j=0;j<=mx;j++) {
        cout<<dp[i][j]<<" ";
      } cout<<endl;
    }*/
  }
  
  ll an=0;
  for(int i=1;i<=n;i++) {
    an += dp[i][i*a];
    //cout<<dp[i][i*a]<<" ";
  }
  cout<<an<<endl;
}

Measured memory_bytes: 1280
#include<iostream>
#include<stdio.h>
#include<string>

using namespace std;

int main()
{
	string s;
	cin >> s;
	size_t size = s.length(); 

	for(int i=0;i<size;i++){
	    cout<<'x';
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
N = input().split()
r = int(N[0])
c = int(N[1])
d = [[0 for i in range(c)] for j in range(r)]
for i in range(r):
    data = input().split()
    for j in range(c):
        d[i][j] = int(data[j])
sum2 = [0 for i in range(c)]
for i in range(r):
    line = ''
    for j in range(c):
        line += str(d[i][j])
        line += ' '
        sum2[j] += d[i][j]
    line += str(sum(d[i]))
    print(line)
line2 = ''
for i in range(c):
    line2 += str(sum2[i])
    line2 += ' '
print('{0}{1}'.format(line2, sum(sum2)))

Measured memory_bytes: 7836
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i=1; 2*(i+1)<=n; i++){
        if(s.substr(0,(n-2*i)/2)==s.substr((n-2*i)/2,(n-2*i)/2)){
            cout << n-i*2 << endl;
            return 0;
        }
    }
    return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N, E, T;
int x[110000], dp[110000];
signed main() {
    cin >> N >> E >> T;
    for (int i = 0; i < N; i++)cin >> x[i];
    x[N] = E;
    dp[N] = 0;
    int rmin = 1e14;
    int lidx = N;
    for (int i = N - 1; i >= 0; i--) {
        rmin += 2 * (x[i + 1] - x[i]);
        while (T < 2 * (x[lidx - 1] - x[i]))rmin = min(rmin, dp[lidx] + 2 * (x[lidx - 1] - x[i])), lidx--;
        dp[i] = min(rmin, dp[lidx] + T);
    }
    cout << E + dp[0] << endl;;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(X, Y);
  GI2(Z, K);
  vector<ll> A(X), B(Y), C(Z);
  FOR(i, X) cin >> A[i];
  FOR(i, Y) cin >> B[i];
  FOR(i, Z) cin >> C[i];
  vector<ll> AB(X * Y);
  for (int a = 0; a < X; ++a) {
    for (int b = 0; b < Y; ++b) {
      AB[a * Y + b] = A[a] + B[b];
    }
  }
  sort(ALL(AB), greater<ll>());
  vector<ll> ABC;
  for (int i = 0; i < min(X * Y, K); ++i) {
    for (int c = 0; c < Z; ++c) {
      ABC.push_back(AB[i] + C[c]);
    }
  }
  sort(ALL(ABC), greater<ll>());
  FOR(i, K) print(ABC[i]);
  return 0;
}

Measured memory_bytes: 42984
import math
N = int(input())
ans = [(0, 0)]
def rec(i, lx, ly, rx, ry):
    if i == N:
        return ans
    else:
        x1 = (2 * lx + rx) / 3
        y1 = (2 * ly + ry) / 3
        x3 = (2 * rx + lx) / 3
        y3 = (2 * ry + ly) / 3
        x2 = (x3 - x1) * math.cos(math.pi/3) \
             - (y3 - y1) * math.sin(math.pi/3) + x1
        y2 = (x3 - x1) * math.sin(math.pi/3) \
             + (y3 - y1) * math.cos(math.pi/3) + y1
        

        rec(i+1, lx, ly, x1, y1)
        ans.append((x1, y1))

        rec(i+1, x1, y1, x2, y2)
        ans.append((x2, y2))

        rec(i+1, x2, y2, x3, y3)
        ans.append((x3, y3))

        rec(i+1, x3, y3, rx, ry)

        return ans
        

answer = rec(0, 0, 0, 100, 0)
answer.append((100, 0))
for pair in answer:
    print(*pair)


Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int INF = 1e9;

struct Node {
    int vertex;
    int dist;
    
    Node(int vertex, int dist):vertex(vertex), dist(dist){}
    
    bool operator<(const Node& other) const {
        return dist > other.dist;
    }
};

struct Edge {
    int from, to;
    int weight;
    Edge(int from, int to, int weight):from(from), to(to), weight(weight){}   
};

struct Dikstra {
    int n;
    vector<Edge> edges;
    vector<vector<int>> g;
    vector<int> dists;
    
    Dikstra(int n):n(n) {
        g.assign(n + 1, vector<int>());
        dists.assign(n + 1, INF);
    }
    
    void addEdge(int from, int to, int w) {
        edges.push_back(Edge(from , to, w));
        g[from].push_back(edges.size() - 1);
    }
    
    void solve(int s) {
        priority_queue<Node> q;
        vector<bool> visited(n + 1, false);
        dists[s] = 0;
        q.push(Node(s, 0));
        
        while (!q.empty()) {
            Node u = q.top(); q.pop();
            if (visited[u.vertex]) {
                continue;
            }
            visited[u.vertex] = true;
            for (int edgeId : g[u.vertex]) {
                Edge edge = edges[edgeId];
                if (!visited[edge.to] && dists[u.vertex] + edge.weight < dists[edge.to]) {
                    dists[edge.to] = dists[u.vertex] + edge.weight;
                    q.push(Node(edge.to, dists[edge.to]));
                }
            }
        }   
    }
    
};

int main() {
    int v, e, s;
    cin >> v >> e >> s;
    Dikstra d(v);
    for (int i = 0; i < e; i++) {
        int from, to, w;
        cin >> from >> to >> w;
        d.addEdge(from, to, w);
    }
    d.solve(s);
    
    for (int i = 0; i < v; i++) {
        if (d.dists[i] == INF) {
            cout << "INF" << endl;
        }
        else {
            cout << d.dists[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 16924
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(theta:i32);
    let S = 12*3600/360*theta;
    let h = S/3600;
    let m = S%3600/60;
    println!("{} {}",h,m);
}


Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
const long long inf=1e15;
long long dp[2501][11000];
struct edge{
    int u,v,w;
};
void upd(long long &a,long long b){
    a=max(a,b);return;
}
edge e[5002];
int n,m,p;

int main(){
    int u,v,w;
    scanf("%d%d%d",&n,&m,&p);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
    }
    for(int j=0;j<=2*m;j++)
    for(int i=1;i<=n;i++)
        dp[i][j]=-inf;
    dp[1][0]=0;
    for(int j=1;j<=2*m;j++){
        for(int i=1;i<=m;i++){
            upd(dp[e[i].v][j],dp[e[i].u][j-1]+e[i].w);
        }
    }
    long long ans=-inf;
    for(int j=1;j<=m;j++){
        upd(ans,dp[n][j]-1LL*p*j);
    }
    long long nans=-inf;
    for(int j=m+1;j<=2*m;j++){
        upd(nans,dp[n][j]-1LL*p*j);
    }
    if(nans>ans){
        return !printf("-1");
    }
    upd(ans,0LL);
    printf("%lld\n",ans);

}
/*
    Good Luck
        -Lucina
*/


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

int main(){
	
	int n, m;
	cin>>n>>m;
	int a[100][100];
	int b[100];
	int c[100];

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

	for(int i = 0; i < n; i++){
		c[i] = 0;
		for(int j = 0; j < m; j++){
				c[i] += a[i][j] * b[j];
		}
	}

	for(int i = 0; i < n; i++){
		cout<<c[i]<<endl;
	}

	return 0;
}

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

using namespace std;
using ll = long long;

int main(void) {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (i == k - 1) {
      if (s[i] == 'A') cout << 'a';
      if (s[i] == 'B') cout << 'b';
      if (s[i] == 'C') cout << 'c';
      continue;
    }
    cout << s[i];
  }
  cout << endl;
  return 0;
}


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

#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

const int mod = 1e9+7;
const int inf = 2e18;

int32_t main()
{	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin>>s;

	if(s=="ABC")
		cout<<"ARC"<<'\n';
	else
		cout<<"ABC"<<'\n';

	return 0;
}	

Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
import fractions
def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

class segtree():#seg=segtree(A),単位元とsegfuncを指定すること
    def __init__(self,A,ide=0):#単位元とsegfuncを指定すること
        n=len(A)
        num=2**(n-1).bit_length()
        seg=[ide]*(2*num-1)
        segfunc=self.segfunc
        self.ide,self.n,self.num,self.seg = ide, n, num, seg
        for i in range(n): seg[i+num-1]=A[i]#setvalue
        for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])#build
            
    def segfunc(self,x,y):return fractions.gcd(x,y) #seg木の基本関数
        
    def update(self,k,x):#Aのk番目の要素をxに置き換える,計算量log(N)
        k += self.num-1
        seg,segfunc=self.seg,self.segfunc
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
    def query(self,p,q):#区間[p,q)の累積segfuncを求める,計算量log(N)
        if q<=p: return self.ide
        num,segfunc,seg=self.num,self.segfunc,self.seg
        p += num-1; q += num-2
        res=self.ide
        while q-p>1:
            if p&1 == 0: res = segfunc(res,seg[p])
            if q&1 == 1:
                res = segfunc(res,seg[q])
                q -= 1
            p,q = p//2, (q-1)//2
        if p == q: res = segfunc(res,seg[p])
        else: res = segfunc(segfunc(res,seg[p]),seg[q])
        return res

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    seg=segtree(A)
    ans=1
    for i in range(N):
        seg.update(i,0)
        ans=max(ans,seg.query(0,N))
        seg.update(i,A[i])
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 89620
#include<stdio.h>

int main (void)
{
	int a ,b, c;
	
	scanf( "%d" "%d" "%d", &a, &b, &c);
	
	if(a > b){
		if(a > c){
			if(b > c){
				printf("%d %d %d\n",c ,b ,a);
			}else{
				printf("%d %d %d\n",b ,c ,a);
			}
				
		}else{
			printf("%d %d %d\n",b ,a ,c);
		}
			
	}else{
		if(a > c){
			printf("%d %d %d\n",c ,a ,b);
				
		}else{
			if(b > c){
				printf("%d %d %d\n",a ,c ,b);
			}else{
				printf("%d %d %d\n",a ,b ,c);
			}
		}
	
	}
	
	return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize("O3")
#include <atcoder/all>
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

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

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n;
int res;

void spr(int a){
  int b = n/a;if(b == 1 || gcd(a,b) != 1)return;
  int k = atcoder::inv_mod(a,b);
  debug(a,b,k);
  if(a * k == 1){
    k += b;
  }
  mini(res,a*k - 1);
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  if(n == 1){
    cout << 1 << "\n";
    return 0;
  }
  n *= 2;
  res = n;
  for(int x = 1; x * x <= n; x++){
    if(n % x == 0){
      spr(x);
      spr(n/x);
    }
  }
  cout << res << "\n";
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	cin>>k;
	  queue <long long> q;
	for(int i = 1; i < 10; i++)
	 	q.push(i);

	 long long ans = 0;

	for(int i = 0; i<k; i++)
	{
		long long x = q.front();
		q.pop();
		if(i == k-1){ans=x;}
		if(x%10!=0){q.push(x*10+x%10-1);}
		q.push(x*10+x%10);
		if(x%10!= 9){q.push(x*10+x%10+1);}
		
	}
	cout<<ans<<endl;
	 return 0;

}

Measured memory_bytes: 1792
from operator import itemgetter
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


class UF_tree:
    def __init__(self, n):
        self.root = [-1] * (n + 1)  # -1ならそのノードが根,で絶対値が木の要素数
        self.rank = [0] * (n + 1)

    def find(self, x):  # xの根となる要素番号を返す
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def getNodeLen(self, x):
        return -self.root[self.find(x)]


if __name__ == "__main__":
    N = int(input())
    XY = []
    for i in range(N):
        x, y = map(int, input().split())
        XY.append((x, y, i))

    edge = []
    XY.sort()
    for (x1, _, i), (x2, _, j) in zip(XY[:-1], XY[1:]):
        edge.append((x2 - x1, i, j))

    XY.sort(key=itemgetter(1))
    for (_, x1, i), (_, x2, j) in zip(XY[:-1], XY[1:]):
        edge.append((x2 - x1, i, j))

    uf = UF_tree(N + 10)
    edge.sort()
    ans = 0
    for cost, x, y in edge:
        if uf.isSame(x, y):
            continue
        uf.unite(x, y)
        ans += cost
    print(ans)

Measured memory_bytes: 45240
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int p[1100];

int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	long long L=0;
	long long R=0;
	int t=-mod;
	int s=0;
	for(int i=0;i<a;i++){
		if(i%2==0&&p[i]>0)L+=p[i];
		if(i%2==1&&p[i]>0)R+=p[i];
		t=max(t,p[i]);
		if(t==p[i])s=i;
	}
	if(t<0){
		printf("%d\n",t);
		printf("%d\n",a-1);
		for(int i=0;i<s;i++)printf("1\n");
		for(int i=0;i<a-1-s;i++)printf("%d\n",a-s-i);
		return 0;
	}
	vector<int>v;
	if(L>R){
		printf("%lld\n",L);
		int at=0;
		while(at<a){
			if(at%2==0&&p[at]>0){
				break;
			}
			v.push_back(1);
			at++;
		}
		int las=0;
		while(at+2<a){
			if(p[at+2]>0){
				las=2;
				v.push_back(2);
			}else{
				las=3;
				v.push_back(3);
			}
			at+=2;
		}
		if(las<=2)at++;
		if(at<a)v.push_back(2);

	}else{
		printf("%lld\n",R);
		int at=0;
		while(at<a){
			if(at%2==1&&p[at]>0){
				break;
			}
			v.push_back(1);
			at++;
		}
		int las=0;
		while(at+2<a){
			if(p[at+2]>0){
				las=2;
				v.push_back(2);
			}else{
				las=3;
				v.push_back(3);
			}
			at+=2;
		}
		if(las<=2)at++;
		if(at<a)v.push_back(2);
		
	}
	printf("%d\n",(int)v.size());
	for(int i=0;i<v.size();i++)printf("%d\n",v[i]);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int n,a,b;
  cin>>a>>b;
  if(b%a==0)ou(a+b);
  else ou(b-a);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const double EPS = 1e-7;
const double INF = 1e12;
struct Vec {
    double x,y;
    Vec(){}
    Vec(double x,double y){ this->x=x,this->y=y; }
    void read(){ scanf("%lf%lf",&x,&y); }
    void prt() {printf("%.9f %.9f\n",x,y); }
    double len(){ return sqrt(x*x+y*y); }
    double len2(){ return x*x+y*y; }
    
    Vec operator+(const Vec&o)const{ return Vec(x+o.x,y+o.y); }
    Vec operator-(const Vec&o)const{ return Vec(x-o.x,y-o.y); }
    Vec operator*(const double&k)const{ return Vec(k*x,k*y); }
    double operator*(const Vec&o)const {return x*o.x+y*o.y; }
    double operator^(const Vec&o)const {return x*o.y-y*o.x; }
    Vec rotate(double ang){ return Vec(x*cos(ang)-y*sin(ang), x*sin(ang)+y*cos(ang)); }
    Vec change(double l){ if(len()<EPS) return *this; return (*this)*(l/len()); }
    double disToLine(Vec A, Vec B) {
        return abs((A-*this)^(B-*this))/(B-A).len();
    }
};

Vec Lineintersect(Vec A1,Vec A2,Vec B1,Vec B2) {
    if (abs((A2-A1)^(B2-B1)) < EPS) return Vec(INF,INF);
    return A1 + (A2 - A1) * ((abs((A2-A1)^(B2-B1)) - abs((A2-B1)^(B2-B1)) ) / abs((A2-A1)^(B2-B1)));
}

Vec Segintersect(Vec A1,Vec A2,Vec B1,Vec B2) {
    Vec P = Lineintersect(A1,A2,B1,B2);
    if ((P-A1)*(P-A2)<=0 && (P-B1)*(P-B2)<=0) return P; 
    return Vec(INF,INF);
}

Vec p1,p2;
int main(){
    p1.read(); p2.read();
    int q; scanf("%d",&q);
    while(q--){
        Vec p; p.read();
        double dis = p.disToLine(p1,p2);
        int sgn = ((p2-p1)^(p-p1))>=0?-1:+1;
        //(p2-p1).rotate(acos(-1)/2).prt();
        p=p+(p2-p1).rotate(acos(-1)/2).change(dis)*sgn;
        p.prt();
    }
}


Measured memory_bytes: 3240
<?php

[$X, $N ] = fscanf(STDIN, "%d%d");
$list = fscanf(STDIN, str_repeat("%d", $N));
sort($list);
$near = $X + 1;
$near_value = -1;

for($i = 0;$i<=101;$i++){
    if(!in_array($i,$list)){
        if(abs($X - $i) < $near){
            $near = abs($X- $i);
            $near_value = $i;
        }
    }
}

echo $near_value;

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

#define pb push_back

#define int ll
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

template<typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (const T& x : v)
    o << x << ",";
  return o << "]";
}

const int INF = 2e9;

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

  string n;
  cin >> n;
  if (n[0] == '7' || n[1] == '7' || n[2] == '7')
    cout << "Yes\n";
  else
    cout << "No\n";
}


Measured memory_bytes: 3652
import numpy as np


def main():
    N, D = map(int, input().split())
    p = [np.array(list(map(int, input().split()))) for _ in range(N)]
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            d = np.sqrt(np.sum(np.power(p[i] - p[j], 2)))
            if d % 1 == 0:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13420
fun main (args: Array<String>) {
	
	val rnum = readLine()
	val list = readLine()!!.split(" ").map(String::toInt)
	
	var hnum = 0
	var vnum = list[0]
	var result = 0
	
	for (i in 0..list.size - 1) {
		hnum = list[i]
		
		if (hnum >= vnum || hnum == vnum) {
			vnum = hnum
			result += 1
			
		}
		
	}
	
	println("${result}")
	
}

Measured memory_bytes: 37732
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, d, x;
    int a[100];
    int ans = 0;
    cin >> n >> d >> x;
    rep(i, n) {
        cin >> a[i];
        ans += (d - 1) / a[i] + 1;
    }
    cout << ans + x << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
p=0
for i in range(N):#O(200000)
  p=p^a[i]
#これでpは各猫のxorになったはず
ls=[]
for i in range(N):#O(200000)
  ls.append(p^a[i])
print(' '.join(map(str, ls)))

Measured memory_bytes: 41852
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N = LSI()
dp = [[INF]*2 for _ in range(len(N)+1)] #dp[i][0]が下からi桁めをぴったり払う最低枚数
dp[0][0] = 0
for i in range(len(N)):
    d = N[-(i+1)]
    dp[i+1][0] = min(dp[i][0] + d, dp[i][1] + d + 1)
    dp[i+1][1] = min(dp[i][0] + (10-d), dp[i][1] + (10-d) - 1)
print(min(dp[-1][0], dp[-1][1]+1))


Measured memory_bytes: 221080
#include <iostream>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int H, W, N;
int initDir[1000][1000];
int visitCnt[1000][1000];

int main() {
    int y, x;
    
    while (true) {    //複数テストケース
        cin >> H >> W >> N;
        if (H == 0 && W == 0 && N == 0) {
            break;
        }
        
        rep(y, H) rep(x, W) cin >> initDir[y][x];

        //初期化
        rep(y, H) {
            rep(x, W) {
                visitCnt[y][x] = 0;
            }
        }
        
        //1～N-1回目までで各マスに何回訪れたか？
        visitCnt[0][0] = N - 1;
        rep(y, H) {
            rep(x, W) {
                int cnt = visitCnt[y][x];
                //右
                if (x + 1 < W) {
                    visitCnt[y][x + 1] += cnt / 2;
                    if (cnt % 2 == 1 && initDir[y][x] == 1) { //東が最初
                        visitCnt[y][x + 1] += 1;
                    }
                }
                //下
                if (y + 1 < H) {
                    visitCnt[y + 1][x] += cnt / 2;
                     if (cnt % 2 == 1 && initDir[y][x] == 0) { //南が最初
                        visitCnt[y + 1][x] += 1;
                     }
                }
            }
        }

        //N回目の散歩のシミュレーション
        y = 0;
        x = 0;
        while (y < H && x < W) {
            //y行x列目の方向を調べる
            int dir = (initDir[y][x] + visitCnt[y][x]) % 2;
            if (dir == 0) { //南
                y++;
            }
            else { //東
                x++;
            }
        }

        cout << y + 1 << " " << x + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 10828