akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace _0281
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int ret = x.Min();
                x[0] -= ret; x[1] -= ret; x[2] -= ret;
                int a = Math.Min(x[0] / 2, x[1]);
                ret += a;
                x[0] -= a * 2; x[1] -= a;
                ret += x[0] / 3;
                Console.WriteLine(ret);
            }
        }
    }
}

Measured memory_bytes: 9552
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int H,W;
  scanf("%d%d",&H,&W);

  char S[H][W+1];
  for (int i = 0; i < H; i++) {
    scanf("%s",S[i]);
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if(S[i][j] == '.') continue;
      if(j != 0) if(S[i][j-1] == '#') continue;
      if(i != 0) if(S[i-1][j] == '#') continue;
      if(j != W-1) if(S[i][j+1] =='#') continue;
      if(i != W-1) if(S[i+1][j] =='#') continue;

      printf("No\n");
      return 0;
    }
  }

  printf("Yes\n");

  return 0;
}

Measured memory_bytes: 128
/*
	0148:Candy and Class Flag
*/
#include	<iostream>
#include	<cstdio>

using namespace std;

int main(void) {
	while(1) {
		int i, r;
		
		cin >> i;
		if( cin.eof() ) { break; }
		
		printf("3C%02d\n", (i - 1) % 39 + 1);
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int n,m;
vi dp;
vs in;
vi tovi(int a){
	vi out(m);
	int t=0;
	while(a){
		out[t++]=a%3;
		a/=3;
	}
	return out;
}
int toi(vi a){
	int out=0;
	int t=1;
	rep(i,m){
		out+=t*a[i];
		t*=3;
	}
	return out;
}
vi q;
int f(int a){
	if(dp[a]!=inf)return dp[a];
	vi t=tovi(a);
	int co=0;
	rep(i,n){
		bool h=true;
		rep(j,m)if(t[j]!=2&&in[i][j]-'0'!=t[j])h=false;
		co+=h;
	}
	if(co<=1)return dp[a]=0;
	int mi=inf;
	rep(i,m)if(t[i]==2){
		t[i]=0;
		int t1=f(toi(t));
		t[i]=1;
		int t2=f(toi(t));
		t[i]=2;
		mi=min(mi,max(t1,t2)+1);
	}
	return dp[a]=mi;
}
int main(){
	while(cin>>m>>n,n){
		q=vi(m,2);
		q[0]=0;
		in=vs(n);
		rep(i,n)cin>>in[i];
		dp=vi(pow(3,m),inf);
		cout<<f(toi(vi(m,2)))<<endl;
	}
}

Measured memory_bytes: 4464
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
typedef long long ll;
typedef std::pair<int,int> pii;
#define lson rt<<1
#define rson rt<<1|1
#define clr(a,x) memset(a,x,sizeof(a))
#define FOR(i,a,b) for(int i=(a);i<=(int)(b);++i)
#define REP(i,a,b) for(int i=(a);i>=(int)(b);--i)
#define EFOR(i,u) for(int i=lnk[u];i;i=nxt[i])
#define DEBUG(x) std::cerr<<#x<<" = "<<x<<'\n'
const int inf=1<<30;
const long long INF=1LL<<61;
void judge() {
#ifdef SIYUAN
	freopen("in.txt","r",stdin);
#endif
}
inline char nc() {
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
template <class Tp> inline void read(register Tp &s) {
	s=0;bool neg=0;char c=nc();for(;c<'0'||c>'9';neg|=(c=='-'),c=nc());
	for(;c>='0'&&c<='9';s=10*s+(c^48),c=nc());neg&&(s=-s);
}
int pow(int x,int p,int mod) {
	int res=1;
	for(;p;p>>=1,x=1LL*x*x%mod) if(p&1) res=1LL*res*x%mod;
	return res;
}
int gcd(int x,int y) {return y?gcd(y,x%y):x;}

int main() {
//	judge();
	int n,t,a,pos;
	double mn=1e50;
	std::cin>>n>>t>>a;
	FOR(i,1,n) {
		int x;
		std::cin>>x;
		if(std::fabs(t-0.006*x-a)<mn) mn=std::fabs(t-0.006*x-a),pos=i;
	}
	std::cout<<pos<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
		int A,B;
    	cin >> A >> B;
    	if (A <= 9 && B <= 9){
			cout << A*B << endl;
	    }
    	else {
    		cout << -1 << endl;
    	}
    }

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	map<int, int> mp;
	REP(i, n)
	{
		int a;
		cin >> a;
		mp[a]++;
	}

	int s = (*mp.begin()).first;
	int e = (*mp.rbegin()).first;
	int cost = 100 * 100 * 100;
	FOR(i, s, e + 1)
	{
		int c = 0;
		REPIT(mp)
		{
			c += pow(i - (*it).first, 2) * (*it).second;
		}
		if (cost > c)
		{
			cost = c;
		}
	}

	print(cost);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
def dfs(depth,s,m):
    global maxdepth,target,cnt
    if depth==maxdepth:
        if s==target:
            cnt+=1
        return
    r=min([target-s,9])+1
    for i in range(r):
        if i>m:
            dfs(depth+1,s+i,i)
while 1:
    maxdepth,target=[int(st)for st in input().split(" ")]
    if maxdepth==target==0:break
    cnt=0
    u=[False for i in range(10)]
    dfs(0,0,-1)
    print(cnt)

Measured memory_bytes: 7776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];
    sort(v.begin(), v.end());
    ll p = 2;
    for(int i = 2; i < n; i++){
        v[i] *= p;
        p *= 2;
    }
    ll s = 0;
    for(int i = 0; i < n; i++)
        s += v[i];
    double ans = (double)s / p;
    printf("%.8f\n",ans);
    return 0;
}

Measured memory_bytes: 3756
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function gcd(a,b){return b?gcd(b,a%b):a;}

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  var gcd0 = gcd(a[0],a[1]);
  var gcd1 = new Set([a[0],a[1]]);
  for(var i = 2; i < n; i++){
    var s = new Set();
    if(1 < gcd0){
      s.add(gcd0);
      gcd0 = gcd(gcd0, a[i]);
    }
    for(var j of gcd1){
      var t = gcd(j,a[i]);
      if(1 < t)s.add(t);
    }
    gcd1 = s;
  }
  var ans = 1;
  for(var i of gcd1)if(ans < i)ans = i;
  return ans;
}

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

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

Measured memory_bytes: 256
def main():
    a, b, c, d = map(int, input().split())

    if b <= c:
        ans = 0
    elif d <= a:
        ans = 0
    else:
        if c <= a:
            if d <= b:
                ans = d - a
            else:
                ans = b - a
        else:
            if b <= d:
                ans = b - c
            else:
                ans = d - c

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S,T;cin>>S>>T;
    int A,B;cin>>A>>B;
    string U;cin>>U;
    if(U==S){
        A=A-1;
    }
    else{
        B=B-1;
    }
    cout<<A<<" "<<B;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
from numba import njit, prange
import numpy as np
INF = 10**18

@njit('(i8, i8[:,:])')
def solve(N, XYP):
    X = XYP[:, 0]
    Y = XYP[:, 1]

    def calcCost(sign, A):
        ret = np.ones((1 << N, N), dtype=np.int64) * INF
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i in prange(N):
                xyp = XYP[i]
                cost = abs(xyp[sign])
                for z in useA:
                    cost = min(cost, abs(xyp[sign] - z))
                ret[state][i] = cost * xyp[2]
        return ret

    costX = calcCost(0, X)
    costY = calcCost(1, Y)
    ans = np.ones(N + 1, dtype=np.int64) * INF

    for state in range(pow(3, N)):
        stateX = 0
        stateY = 0
        M = N
        for _ in range(N):
            state, r = divmod(state, 3)
            stateX <<= 1
            stateY <<= 1
            if r == 0: M -= 1
            if r == 1: stateX |= 1
            if r == 2: stateY |= 1

        cx, cy = costX[stateX], costY[stateY]
        cost = 0
        for i in prange(N):
            cost += min(cx[i], cy[i])
        ans[M] = min(ans[M], cost)

    for a in ans:
        print(a)

def sol():
    N = int(input())
    XYP = np.asarray([list(map(int, input().split())) for _ in range(N)])
    solve(N, XYP)

sol()


Measured memory_bytes: 139116
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        String ans = "";
        ans = input.equals("A") ? "T" : ans;
        ans = input.equals("T") ? "A" : ans;
        ans = input.equals("C") ? "G" : ans;
        ans = input.equals("G") ? "C" : ans;

        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	ll n, t;
	cin >> n >> t;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	a.pb(INF);
	ll ans = 0;
	rep(i, n) ans += min(t, a[i + 1] - a[i]);
	cout << ans << '\n';
}

Measured memory_bytes: 4480
import java.math.BigDecimal;
import java.util.Scanner;

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

			String a = sc.next();
			String b = sc.next();
			
			BigDecimal bigA = new BigDecimal(a);
			BigDecimal bigB = new BigDecimal(b);
			
			
			BigDecimal c = bigA.multiply(bigB);
			
			long ans = c.longValue();
			
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 35964
#include <stdio.h>

int h, w, diff[80][80];
char dp[80][80][80*(80+80)+1];

int abs (int x) { return x < 0 ? - x : x; }

int main (void) {
	int a, x, y, d, d1, d2;
	
	scanf("%d %d", &h, &w);
	
	for (y = 0; y < h; y++) {
		for(x = 0; x < w; x++) {
			scanf("%d", &diff[x][y]);
		}
	}
	
	for(y = 0; y < h; y++) {
		for(x = 0;x<w;x++)
		{
			scanf("%d", &a);
			diff[x][y] = abs(diff[x][y] - a);
		}
	}
	
	dp[0][0][diff[0][0]] = 1;
	for(y=0;y<h;y++){
		for(x=0;x<w;x++)
		{
			for(d=0;d<=(80+80)*80;d++) {
		  	d1 = abs(d-diff[x][y]);
	  		d2 = abs(d+diff[x][y]);
				if(x>0 && (dp[x-1][y][d1] || dp[x-1][y][d2])) {
					dp[x][y][d] = 1;
					continue;
				}
				if(y>0 && (dp[x][y-1][d1] || dp[x][y-1][d2])) {
					dp[x][y][d] = 1;
				}
			}
		}
	}
	
	for(d=0;!dp[w-1][h-1][d];d++)
	{
	}
	
	printf("%d\n", d);
}

Measured memory_bytes: 79744
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct SegmentTree {
    struct Node {
        Node operator*(const Node &o) const {
            return { v | o.v };
        }
        int v;
    };

    SegmentTree(int n) : e({ 0 }), n(n) {
        for (m = 2; m < n; m *= 2);
        t = vector<Node>(m + n + n % 2, e);
    }
    Node &operator[](int i) {
        return t[m + i];
    }
    const Node &root() const {
        return t[1];
    }
    void build() {
        for (int i = (n - 1 + m) / 2; i > 0; i--) t[i] = t[i * 2] * t[i * 2 + 1];
    }
    void update(int i, const Node &o) {
        for (t[i += m] = o; i /= 2, i > 0;) t[i] = t[i * 2] * t[i * 2 + 1];
    }
    Node query(int l, int r) {
        Node o[2] = { e, e };
        for (l += m, r += m; l < r; l /= 2, r /= 2) {
            if (r & 1) o[1] = t[--r] * o[1];
            if (l & 1) o[0] = o[0] * t[l++];
        }
        return o[0] * o[1];
    }
    void print() {
        for (int j = 1; j <= m; j *= 2) {
            int k = min(j * 2, m + n);
            for (int i = j; i < k; i++) {
                cout << t[i].v << " \n"[i == k - 1];
            }
        }
    }
    vector<Node> t;
    const Node e;
    int n, m;
};

using ull = unsigned long long;
constexpr ull f(int i) {
    return ~0ULL / (1 + (1ULL << (1 << i)));
}
int popcnt(ull t) {
    t = (t & f(0)) + (t >> 1 & f(0));
    t = (t & f(1)) + (t >> 2 & f(1));
    t = (t & f(2)) + (t >> 4 & f(2));
    t = (t & f(3)) + (t >> 8 & f(3));
    t = (t & f(4)) + (t >> 16 & f(4));
    t = (t & f(5)) + (t >> 32);
    return t;
}

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

    int n;
    string s;
    cin >> n >> s;

    SegmentTree st(n);
    for (int i = 0; i < n; i++) {
        st[i] = { 1 << (s[i] - 'a') };
    }
    st.build();

    int q;
    cin >> q;

    for (int h = 0; h < q; h++) {
        int t;
        cin >> t;

        if (t == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;

            st.update(i, { 1 << (c - 'a') });

        } else {
            int l, r;
            cin >> l >> r;
            l--;

            int v = st.query(l, r).v;
            cout << popcnt(v) << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 4892
#include <stdio.h>
#include <algorithm> 
#include <math.h>
using namespace std;
long long a,b,x,y,ans,w,z,k,u;
int main(){
	int q;
	scanf("%d",&q);
	while(q--){
		scanf("%lld%lld",&a,&b);
	x=(long long)sqrt((double)(a*b));
   	if(x*(x+1)<a*b){
   	printf("%lld\n",2*x-1);
   	
	   }
	   else if(x*x<a*b)	{
	   if((x==a)||(x==b)){
	   printf("%lld\n",2*x-2);
	   
}
else{
if(x>=2)printf("%lld\n",2*x-2);
else printf("1\n");
}
}
else{
	if(a==b){
	printf("%lld\n",2*x-2);
	}
	else{
	if(x>=2)printf("%lld\n",2*x-3); 
	else printf("0\n"); 
	}
}
}
  return 0;
}

Measured memory_bytes: 128
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑


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

	for (int i = 0; i < a.length(); ++i) {
		if (a[i] == b[i]) { ++ans; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

bool dp[110000];
int main() {
    ll x; cin >> x;
    rep(i, 110000) dp[i] = 0;
    dp[0] = 1;
    dp[100] = 1;
    dp[101] = 1;
    dp[102] = 1;
    dp[103] = 1;
    dp[104] = 1;
    rep(i, 110000) {
        if(dp[i] || dp[i+1] || dp[i+2] || dp[i+3] || dp[i+4] || dp[i+5]) dp[i+105] = 1;
    }
    cout << dp[x] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


bool pairCompare(const Pi& firstElof, const Pi& secondElof)
{
	return firstElof.second > secondElof.second;
}

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

	int n, m;
	string s;

	cin >> n >> m;
	if (m%n == 0) {
		cout << n + m << endl;
	}
	else {
		cout << m-n << endl;
	}

	return 0;
}



Measured memory_bytes: 256
num = int(input())
fizzBuzz = 0

while(num > 0):
  if(num % 15 == 0):
    num -= 1
    continue
  elif(num % 3 == 0):
    num -= 1
    continue
  elif(num % 5 == 0):
    num -= 1
    continue
  else:
    fizzBuzz += num
    num -= 1

print(fizzBuzz)

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

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, i = mi()
    print(n + 1 - i)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import scala.io.StdIn
import scala.annotation.tailrec

object Main extends App {
  val a = StdIn.readLine
  val b = StdIn.readLine

  val ans = {
    if(a.length > b.length) "GREATER"
    else if(a.length < b.length) "LESS"
    else {
      val ita = a.iterator
      val itb = b.iterator

      @tailrec
      def rec(cha:Char, chb:Char):String = {
        if(cha > chb) "GREATER"
        else if(cha < chb) "LESS"
        else if(!ita.hasNext) "EQUAL"
        else rec(ita.next, itb.next)
      }

      rec(ita.next, itb.next)
    }
  }

  println(ans)
}

Measured memory_bytes: 27208
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N;
ll dp[18][2];
ll keta[17];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    ll M=N;
    int n=-1;
    while(M>0){
        M/=10;
        n++;
    }
    M=N;
    rep(i,0,n+1){
        keta[i]=M%10;
        M/=10;
    }
    rer(i,n+1,0){
        if(i==n){
            dp[i][0]=keta[i]-1;
            dp[i][1]=dp[i][0]+1;
        }
        else{
            dp[i][0]=max(dp[i+1][0]+9,(keta[i]>=1?ll(dp[i+1][1]+keta[i]-1):0));
            dp[i][1]=dp[i+1][1]+keta[i];
        }
    }
    cout <<max(dp[0][1],dp[0][0])<<"\n";
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
after=0
before=0
for i in range(n):
  for j in range(i+1,n):
    if a[i] > a[j]:
      after += 1
    elif a[i] < a[j]:
      before += 1
print((after*k*(k+1)//2 + before*k*(k-1)//2)%(10**9+7))

Measured memory_bytes: 3188
N = int(input())
S = input()

a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
al = list(a)

Sl = list(S)

for i, s in enumerate(Sl):
    idx = al.index(s)
    idx2 = idx + N
    if idx2>=26:
        idx2 -= 26
    Sl[i] = al[idx2]
    
print("".join(Sl))

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / INF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

//===================================== template =========================================================

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    vector<int> x(N); REP(i, N) cin >> x[i];

    vector<int> neg, pos; 
    REP(i, N) 
        if (x[i] < 0) neg.push_back(x[i]); 
        else pos.push_back(x[i]);

    reverse(ALL(neg));
    
    int res = INF;
    FOR(i, 0, K) {
        if (i > neg.size() || K-i > pos.size()) continue;

        int n = 0, p = 0;
        if (i != 0) n = neg[i - 1];
        if (i != K) p = pos[K - i - 1];
        chmin(res, 2 * min(-n, p) + max(-n, p));
    }

    cout << res << endl;
}


Measured memory_bytes: 1404
A, B = map(int, input().split())
amin = -(-A // 0.08)
amax = (A+1) // 0.08
bmin = -(-B / 0.1)
bmax = (B+1) // 0.1

mi = max(amin, bmin)
ma = min(amax, bmax)

if mi > ma:
  print(-1)
else:
  print(int(mi))

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}

template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

template<typename T> void sort(vector<T>& v) {sort(v.begin(), v.end());}

int main() {
  int n, res = 0;
  string a, b, c;
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; ++i) {
    if (a[i] == b[i] && b[i] == c[i]) {
      continue;
    } else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
      ++res;
    } else {
      res += 2;
    }
  }
  cout << res << endl;
}



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

int main(){
  long long n, a[10000];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  cout << *min_element( a, a + n) << " "
       << *max_element( a, a + n) << " "
       << accumulate( a, a + n, 0LL) << endl;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	double ans = double(((N+1) / 2)) / N;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

const long long MOD = 1000000007;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}

long long arr[51];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);

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

    for(int i = 0; i < n; ++i)
        cin >> arr[i];

    long long best = 0;

    for(int left = 0; left < n; ++left){
        for(int right = 0; right + left <= n && right + left <= k; ++right){
            vector<int> gems;
            for(int i = 0; i < left; ++i)
                gems.push_back(-arr[i]);
            for(int i = 0; i < right; ++i)
                gems.push_back(-arr[n - i - 1]);
            sort(gems.begin(), gems.end());
            long long tot = 0;
            for(int diff = k - right - left; diff > 0 && !gems.empty() && gems.back() > 0; --diff)
                gems.pop_back();
            for(auto i : gems)
                tot -= i;
            best = max(best, tot);
            gems.clear();
        }
    }

    cout << best;

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();
        int K = reader.nextInt();
        int ans = 0;
        for (int i=0; i<N; i++) {
            if (K <= reader.nextInt()) ans++;
        }
        System.out.println(ans);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int N, L, x[5050], dp[5050][5050];
const int MOD = (int)1e9 + 7;

void modAdd(int& a, int b, int M) {
	a = (a + b) % M;
}

int main() {
	cin >> N >> L;
	
	memset(dp, 0, sizeof(dp));
	
	for_(i,0,N) {
		cin >> x[i];
		++x[i];
	}
	
	for_(i,0,L+1) dp[0][i] = 1;
	
	int a;
	
	for_(i,0,N) {
		cin >> a;

		for_(j,0,L) {
			int xx = x[i] + j * a;
			if (xx > L) break;
			dp[i + 1][xx] = dp[i][xx - 1]; 
		}
		
		for_(j,1,L+1) modAdd(dp[i + 1][j], dp[i + 1][j - 1], MOD);
	}
	
	int ans = 0;
	
	for_(i,0,L) {
		int xx = x[N - 1] + i * a;
		if (xx > L) break;
		ans = dp[N][xx];
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 100808
#include <stdio.h>
#include <stdbool.h>

#define MAX      100000
#define SENTINEL 2000000000

typedef struct Card_
{
    char suit;
    int value;
} Card;

Card L[MAX / 2 + 1];
Card R[MAX / 2 + 1];

static void merge(Card A[], int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }
    L[n1].value = R[n2].value = SENTINEL;

    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

static void mergeSort(Card A[], int n, int left, int right)
{
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

static int partition(Card A[], int n, int p, int r)
{
    Card x = A[r];
    int i = p - 1;

    for (int j = p; j < r; j++) {
        if (A[j].value <= x.value) {
            i++;
            Card tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }

    i++;
    Card tmp = A[i];
    A[i] = A[r];
    A[r] = tmp;
    return i;
}

static void quickSort(Card A[], int n, int p, int r)
{
    if (p < r) {
        int q = partition(A, n, p, r);
        quickSort(A, n, p, q - 1);
        quickSort(A, n, q + 1, r);
    }
}

int main()
{
    int n;
    Card A[MAX], B[MAX];

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        char s[2];
        int v;
        scanf("%s %d", s, &v);
        A[i].suit = B[i].suit = s[0];
        A[i].value = B[i].value = v;
    }

    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n - 1);

    bool stable = true;
    for (int i = 0; i < n; i++) {
        if (A[i].suit != B[i].suit) {
            stable = false;
            break;
        }
    }

    if (stable) {
        printf("Stable\n");
    } else {
        printf("Not stable\n");
    }

    for (int i = 0; i < n; i++) {
        printf("%c %d\n", B[i].suit, B[i].value);
    }

    return 0;
}


Measured memory_bytes: 4072
Plan=input()
N,W,S,E=Plan.count("N"),Plan.count("W"),Plan.count("S"),Plan.count("E")
if (N==0 and S>=1) or (N>=1 and S==0) or (W==0 and E>=1) or (W>=1 and E==0):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define min(...) minn(__VA_ARGS__)
#define max(...) maxx(__VA_ARGS__)
#define stringio() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
char _;
typedef long long ll;
typedef pair<int,int> pii;
template<typename t>constexpr const t minn(const t x,const t y){return x<y?x:y;}
template<typename t,typename ...r>constexpr const t minn(const t x,const r ...xs){return minn(x,minn(xs...));}
template<typename t>constexpr const t maxx(const t x,const t y){return x>y?x:y;}
template<typename t,typename ...r>constexpr const t maxx(const t x,const r ...xs){return maxx(x,maxx(xs...));}
template <typename t> void scan (t& x) {do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0);}
template <typename t, typename ...r> void scan (t& x, r&... xs) {scan(x); scan(xs...);}
const int MAXN = 2e5+2;
bool poss[MAXN], ans[MAXN];
int main() {
    int n;
    scan(n);
    vector<int> a(n+1);
    for (int i = 1; i <= n; i++) scan(a[i]);
    for (int i = n; i > (n>>1); i--) poss[i] = 1, ans[i] = a[i];
    for (int i = (n>>1); i > 0; i--) {
      int tot = 0;
      for (int j = i; j <= n; j += i) tot += ans[j];
      ans[i] = (tot&1) != a[i];
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) cnt += ans[i];
    printf ("%d\n",cnt);
    vector<int> fin;
    for (int i = 1; i <= n; i++) if (ans[i]) fin.push_back(i);
    for (int i = 0; i < cnt; i++) printf ("%d%c",fin[i],i==cnt-1?'\n':' ');
    return 0;
}


Measured memory_bytes: 2680
#include<stdio.h>


int search(int A[],int n,int key){
	int i=0;
	A[n]=key;
	while(A[i]!=key)i++;
	return i!=n;
}

int main(){
	int i,n,A[10000+1],q,key,sum=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&A[i]);
	
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&key);
		if(search(A,n,key))sum++;
	}
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60; 

int main()
{
  ll X; cin >> X;
  ll num500 = X/500;
  ll num5 = (X-num500*500)/5;
  ll ans = num500*1000 + num5*5;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    int N, T, A;
    cin >> N >> T >> A;

    vector<pair<double,int>> H(N);
    REP(i,N) {
        cin >> H[i].first;
        H[i].second = i+1;
    }
    REP(i,N) H[i].first = abs(A-(T-H[i].first*0.006));

    sort(ALL(H));


    cout << H[0].second << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

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

        // 入力
        int[] word = new int[3];
        word[0] = sc.nextInt();
        word[1] = sc.nextInt();
        word[2] = sc.nextInt();

        // 処理
        Arrays.sort(word);
        String out;
        if (word[0] == 5 && word[1] == 5 && word[2] == 7){
            out = "YES";
        } else {
            out = "NO";
        }


        // 出力
        System.out.println(out);
    }

}

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

int main()
{
    int n;
    cin>>n;
    vector<double> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end());
    for(int i=0;i<n-1;i++){
        v[i+1]=(v[i]+v[i+1])/2;
    }
    cout<<v[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int n;
vector<int> d;

bool func(){
    int t = n - 1;
    for(int i = n - 2; i >= 0; i--){
        if(d[i] + i >= t) t = i;
    }
    reverse(d.begin(), d.end());
    return t == 0;
}

int main(){
    cin >> n;
    d = vector<int>(n);

    for(int i = 0; i < n; i++){
        cin >> d[i];
        d[i] /= 10;
    }

    if(func() && func()) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}


Measured memory_bytes: 3884
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
        self.size = [1] * n
        # self.group_num = n

    def root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.root(self.table[x])
            return self.table[x]

    def get_size(self, x):
        r = self.root(x)
        return self.size[r]

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        r1 = self.root(x)
        r2 = self.root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.size[r1] += self.size[r2]
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
            self.size[r2] += self.size[r1]
        # self.group_num -= 1

n, m = LI()
query = LIR(m)
uf = UnionFind(n)
ans = [n * (n - 1) // 2]
for i in range(m - 1, 0, -1):
    a, b = query[i]
    if uf.is_same(a - 1, b - 1):
        ans += [ans[-1]]
    else:
        ans += [ans[-1] - uf.get_size(a - 1) * uf.get_size(b - 1)]
        uf.union(a - 1, b - 1)


for i in ans[::-1]:
    print(i)





Measured memory_bytes: 110556