akhauriyash/Code-Regression huggingface dataset:
package main

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

type Matrix struct {
	r int // num of row
	c int // num of column
}

type Range struct {
	start int // index, inclusive
	end   int // index, inclusive
}

func (r Range) length() int {
	return r.end - r.start + 1
}

func calcMultiplication(x, y Matrix) (Matrix, int) {
	if x.c != y.r {
		panic("cannnot calculate")
	}
	return Matrix{x.r, y.c}, x.r * y.c * x.c
}

func calcMinMatrixChainMultiplication(matrices []Matrix, r Range, memo map[Range]int) (Matrix, int) {
	if v, ok := memo[r]; ok {
		return Matrix{matrices[r.start].r, matrices[r.end].c}, v
	}
	if r.length() == 0 {
		panic("must not be empty")
	} else if r.length() == 1 {
		return matrices[r.start], 0
	}

	var minCount int = math.MaxInt32

	for i := 0; i < r.length()-1; i++ {
		formerRange := Range{r.start, r.start + i}
		latterRange := Range{r.start + i + 1, r.end}
		matF, countF := calcMinMatrixChainMultiplication(matrices, formerRange, memo)
		matL, countL := calcMinMatrixChainMultiplication(matrices, latterRange, memo)
		_, countFL := calcMultiplication(matF, matL)
		count := countF + countL + countFL
		if count < minCount {
			minCount = count
		}
	}
	memo[r] = minCount
	return Matrix{matrices[r.start].r, matrices[r.end].c}, minCount
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, _ := nextInt(sc)
	matrices := make([]Matrix, n)
	for i := 0; i < n; i++ {
		r, _ := nextInt(sc)
		c, _ := nextInt(sc)
		matrices[i] = Matrix{r, c}
	}
	memo := make(map[Range]int)
	_, resultCount := calcMinMatrixChainMultiplication(matrices, Range{0, len(matrices) - 1}, memo)
	fmt.Println(resultCount)
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}



Measured memory_bytes: 1676
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;

const ll mod = 1000000007;
const int N = 2e5+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
ll n;
int main() {
	while(~scanf("%lld", &n)) {
		if(n & 1) {
			printf("0\n");
		} else {
			ll ret = 0;
			n /= 2;
			while(n) ret += (n /= 5);
			printf("%lld\n", ret);
		}
	}
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)



typedef struct t{ll l,r,x;}T;
int sort(const void*a,const void*b){
	T*p=(T*)a,*q=(T*)b;
	if((*p).r<(*q).r)return -1;
	return 1;
}

ll dp[310][310][310];
T c[310];
#define add(p,q)(p=(p+q)%MOD)
int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,m){
		ll l,r,x;
		scanf("%lld%lld%lld",&l,&r,&x);
		c[i].l=l;
		c[i].r=r;
		c[i].x=x;
	}
	qsort(c,m,sizeof(T),sort);
	
	ll cnt=0;
	while(c[cnt].r==1){
		if(c[cnt].x>1){
			puts("0");
			return 0;
		}
		cnt++;
	}
	
	dp[1][0][0]=dp[0][1][0]=dp[0][0][1]=1;
	rep(i,2,n+1){
		//i番目を決める
		rep(j,0,i-1)rep(k,0,i-1){
			add(dp[i  ][j][k],dp[i-1][j][k]);
			add(dp[i-1][i][k],dp[i-1][j][k]);
			add(dp[i-1][j][i],dp[i-1][j][k]);
			add(dp[i][i-1][k],dp[j][i-1][k]);
			add(dp[j][i  ][k],dp[j][i-1][k]);
			add(dp[j][i-1][i],dp[j][i-1][k]);
			add(dp[i][k][i-1],dp[j][k][i-1]);
			add(dp[j][i][i-1],dp[j][k][i-1]);
			add(dp[j][k][i  ],dp[j][k][i-1]);
		}
		while(c[cnt].r==i){
			rep(j,0,i)rep(k,0,i){
				int temp=1;
				if(j>=c[cnt].l)temp++;
				if(k>=c[cnt].l)temp++;
				if(temp!=c[cnt].x){
					dp[i][j][k]=0;
					dp[i][k][j]=0;
					dp[j][i][k]=0;
					dp[k][i][j]=0;
					dp[j][k][i]=0;
					dp[k][j][i]=0;
				}
			}
			cnt++;
		}
	}
	ll ans=0;
	rep(j,0,n)rep(k,0,n){
		add(ans,dp[n][j][k]);
		add(ans,dp[j][n][k]);
		add(ans,dp[j][k][n]);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 227452
N=input()
S=input()
ans=0
for i in range(1000):
    n=str(i).zfill(3)
    x=S.find(n[0])
    y=S.find(n[1],x+1)
    z=S.find(n[2],y+1)
    if x!=-1 and y!=-1 and z!=-1:
        ans+=1
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>

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

  int i,j,ans=1;
  for(i=1;i<x;i++)
    for(j=2;j<11;j++){
      if((pow(i,j)<=x)&&(pow(i,j)>ans))
        ans = pow(i,j);
      else if(pow(i,j)>x)
        break;
    }

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


Measured memory_bytes: 2600
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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 T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

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

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

vector<vector<int>> graph;

//first: distance, second: farthest vertex
P farthest_v(int prev, int v) {
    P res(0, v);
    for (int to: graph[v]) if (to != prev) {
        P t = farthest_v(v, to);
        t.first++;
        if (res.first < t.first) res = t;
    }
    return res;
}

int diameter() {
    P u = farthest_v(-1, 0);
    return farthest_v(-1, u.second).first;
}

int main() {
    int n;
    cin >> n;
    graph.resize(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    
    int d = diameter();
    cout << (d % 3 == 1 ? "Second" : "First") << endl;
}

Measured memory_bytes: 23680
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int A,B;
        {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();
            A = 0;
            B = 0;
            for(int i=0;i<s1.Length;i++){
                if(s1[i] == '1'){
                    if(s2[i] == '1'){
                        A++;
                    }
                    else{
                        B++;
                    }
                }
            }
        }
        Fact F = new Fact(A+B);
        long[,] DP = new long[A+1,B+1];
        for(int i=0;i<=A;i++){
            for(int j=0;j<=B;j++){
                if(i == 0){
                    DP[i,j] = F.f[j]*F.f[j]%Define.mod;
                }
                else{
                    DP[i,j] = (i*j*DP[i-1,j] + j*j*(j == 0 ? 0 : DP[i,j-1])) % Define.mod;
                }
            }
        }
        long count = 0;
        for(int i=0;i<=A;i++){
            count = (count + DP[i,B] * F.GetConv(A+B,A-i) % Define.mod * F.f[A-i] % Define.mod * F.f[A-i] % Define.mod * F.GetConv(A,i)) % Define.mod;
        }
        sb.Append(count+"\n");
    }
}
class Fact{
    public long[] f;
    public long[] rf;
    public Fact(int N){
        f = new long[N+1];
        rf = new long[N+1];
        for(int i=0;i<N+1;i++){
            if(i == 0){
                f[i] = 1;
            }
            else{
                f[i] = (f[i-1]*i)%Define.mod;
            }
        }
        for(int i=N;i>=0;i--){
            if(i == N){
                rf[i] = pow(f[N],Define.mod-2);
            }
            else{
                rf[i] = rf[i+1]*(i+1)%Define.mod;
            }
        }
    }
    public long pow(long N,long K){
        if(K == 0){
            return 1;
        }
        else if(K % 2 == 0){
            long t = pow(N,K/2);
            return t*t%Define.mod;
        }
        else{
            return N*pow(N,K-1)%Define.mod;
        }
    }
    public long GetFact(int N){
        return f[N];
    }
    public long GetConv(int N,int R){
        return ((f[N]*rf[R])%Define.mod*rf[N-R])%Define.mod;
    }
}
public static class Define{
    public const long mod = 998244353;
}

Measured memory_bytes: 108768
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	ll N, sum = 0;

	cin >> N;

	for (int i = 1; i <= N; i++) {
		if (i % 3 == 0 || i % 5 == 0) {

		}
		else {
			sum += i;
		}
	}

	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 3624
x = int(input())
if 400 <= x < 600:
    print(8)
elif 600 <= x < 800:
    print(7)
elif 800 <= x < 1000:
    print(6)
elif 1000 <= x < 1200:
    print(5)
elif 1200 <= x < 1400:
    print(4)
elif 1400 <= x < 1600:
    print(3)
elif 1600 <= x < 1800:
    print(2)
elif  1800 <= x < 2000:
    print(1)


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
 ll n,d=0,k,s=0;
 cin>>n;
 
 k=n;
 while(k!=0){
     d++;
     k=k/10;
 }

 for(ll i=1;i<d;i++){
     if(i%2!=0){
         ll p=0;
         for(ll j=1;j<=i;j++){
             p=p*10+9;
         }
         s+=(p-pow(10,i-1)+1);
         //cout<<s<<" ";
     }
 }
//cout<<d<<" ";

if(d%2!=0)
s+=(n-pow(10,d-1)+1);
cout<<s;
}



Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;

const ll INF=1LL<<61;
const int V_MAX=100000;

struct edge{ int v,cost; };

void pairsort(int n,ll *a,ll *b){
	static pair<ll,ll> c[V_MAX];
	rep(u,n) c[u]=make_pair(a[u],b[u]);
	sort(c,c+n);
	rep(u,n) a[u]=c[u].first, b[u]=c[u].second;
}

template<class T>
class segment_tree{
	static const int N_MAX=1<<17;
	int n;
	vector<T> dat[2*N_MAX];

	int query(int l,int r,int a,int b,int u,ll key){
		if(l<=a && b<=r) return dat[u].end()-lower_bound(dat[u].begin(),dat[u].end(),key);

		int res=0;
		int c=(a+b+1)/2;
		if(l<c && a<r) res+=query(l,r,a,c,2*u  ,key);
		if(l<b && c<r) res+=query(l,r,c,b,2*u+1,key);
		return res;
	}

public:
	void build(int N,const T *a){
		for(n=1;n<N;n*=2);
		rep(u,2*n) dat[u].clear();
		rep(i,n) dat[n+i].push_back(a[i]);
		for(int u=n-1;u>=1;u--){
			int l=2*u,r=2*u+1;
			dat[u].resize(dat[l].size()+dat[r].size());
			merge(dat[l].begin(),dat[l].end(),dat[r].begin(),dat[r].end(),dat[u].begin());
		}
	}

	int query(int l,int r,ll key){ return query(l,r,0,n,1,key); }
};

int main(){
	int n,m; scanf("%d%d",&n,&m);
	static vector<edge> G[V_MAX];
	rep(i,m){
		int u,v,cost; scanf("%d%d%d",&u,&v,&cost);
		G[u].push_back((edge){v,cost});
		G[v].push_back((edge){u,cost});
	}

	static ll ds[V_MAX],dg[V_MAX]; // d_start, d_goal
	rep(t,2){
		ll *d=(t==0?ds:dg);
		int s=(t==0?0:n-1);
		rep(u,n) d[u]=(u==s?0:INF);
		priority_queue< pair<ll,int> > Q; Q.push(make_pair(0,s));
		while(!Q.empty()){
			ll d_now=-Q.top().first;
			int u=Q.top().second; Q.pop();

			if(d[u]<d_now) continue;

			rep(i,G[u].size()){
				int v=G[u][i].v,cost=G[u][i].cost;
				if(d[v]>d[u]+cost){
					d[v]=d[u]+cost;
					Q.push(make_pair(-d[v],v));
				}
			}
		}
	}

	pairsort(n,ds,dg);

	static segment_tree<ll> S;
	S.build(n,dg);

	int q; scanf("%d",&q);
	while(q--){
		ll a,b; scanf("%lld%lld",&a,&b);
		int i=upper_bound(ds,ds+n,a)-ds;
		printf("%d\n",S.query(0,i,b));
	}

	return 0;
}

Measured memory_bytes: 39964
#include <bits/stdc++.h>
using namespace std;
int main(){
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int a,b;
	cin>>a>>b;
	if(a>2*b){
		cout<<a-2*b;
	} 
	else{
		cout<<0;
	} 

}


Measured memory_bytes: 256
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    int a,b,c;cin >> a >> b >> c;
    int g = a+b-c;
    int i = b+c-g;
    int h = a+c-g;
    int d = c+h-a;
    int e = b+d-g;
    int f = c+g-i;
    cout << a << ' ' <<  b << ' ' <<  d << "\n" << e << ' ' <<  c << ' ' <<  f << "\n" << g << ' ' << h << ' ' << i << "\n";
    return 0;
}

Measured memory_bytes: 3612
N,M = map(int,input().split())
X =[]
for i in range(N):
    a,b = map(int,input().split())
    X.append([a,b])
X.sort(key=lambda x: x[0])
count = 0
ans = 0
for i in X:
    if M - count > i[1]:
        count += i[1]
        ans += i[0] * i[1]
        #print(ans,count)
    else:
        x = M - count
        ans += i[0] * x
        break
print(ans)

Measured memory_bytes: 25332
#include <iostream>
#include <cmath>

using namespace std;

#define INF (1 << 4)
typedef unsigned long long ull;

int countDigits(ull num) {
  int ret = 1;
  while (1) {
    ull tmp = num / pow(10,ret);
    if (tmp <= 0) break;
    ++ret;
  }
  return ret;
}

int funcF(ull A, ull B) {
  return max(countDigits(A), countDigits(B));
}

int main() {
  ull N;
  cin >> N;

  ull harf = sqrt(N);
  int ans = INF;
  for (ull A = 1; A <= harf; ++A) {
    ull B = N / A;
    if (A * B == N) {
      ans = min(ans, funcF(A, B));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c;
  a = 0;
  b = 0; 
  c = 0;
  string s;
  in(s);
  rep(i, s.size()){
    if(s[i] == 'S')
      a++;
    else
      b++;
    c = max(c, b - a);
  }
  out(c * 2);
  memi;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define INF 2000000000
#define LINF 9000000000000000000


typedef long long int ll;

int gcd(int m, int n) {
    if ((0 == m) || (0 == n))
        return 0;

    while (m != n) {
        if (m > n) m = m - n;
        else n = n - m;
    }
    return m;
}

int main() {
    ll n;
    cin >> n;
    ll a[n], b[n];

    rep(i, n) {
        cin >> a[i];
    }

    rep(i, n) {
        cin >> b[i];
    }

    ll c[n];

    rep(i, n) {
        c[i] = a[i] - b[i];
    }

    ll plus = 0;
    ll minus = 0;

    rep(i, n) {
        if (c[i] <= -2) {
            minus += (-c[i]) / 2;
        } else if (c[i] >= 1) {
            plus += c[i];
        }
    }

    cout << (minus >= plus ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

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

  vector<int> P(N), Q(N), v(N);
  for (int i = 0; i < N; ++i) cin >> P[i];
  for (int i = 0; i < N; ++i)
  {
    cin >> Q[i];
    v[i] = i + 1;
  }

  int P_num = 0, Q_num = 0, number = 1;
  do
  {
    if (v == P) P_num = number;
    if (v == Q) Q_num = number;
    if (P_num != 0 && Q_num != 0) break;
    ++number;
  
  } while (next_permutation(v.begin(), v.end()));

  cout << abs(P_num - Q_num) << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>

int main() {
	
	int a[3] = {};
	int s = 0;
	cin >> a[0] >> a[1] >> a[2];
	
	while (1) {
		sort(a, a + 3);
		if (a[1] == a[2] && a[2] == a[0])break;
		if (a[0] == a[1]) {
			a[0] += 1;
			a[1] += 1;
		}
		else a[0] += 2;
		s++;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>> 
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>> 
#define pii pair<int,int> 
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(pair<int,int> a, pair<int,int> b)
{
    int l1=a.ss-a.ff+1;
    int l2=b.ss-b.ff+1;
    if(l1!=l2) return l1>l2;
    return a.ff > b.ff;
}
std::priority_queue<pii, std::vector<pii>, std::function<bool(pii, pii)>> pq(Compare);



int32_t main(){ 
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int num=7;
  int k; cin>>k;
  f(i,0,10000007){
    if(num%k==0){
      cout<<i+1<<"\n";
      return 0;
    }
    num*=10; num+=7; num%=k;
  }
  cout<<"-1\n";
  return 0; 
}
// check for overflows dummy !!!


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define getchar gc
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void wri(ll a){write(a); putchar(' ');}
inline void writeln(ll a){write(a); puts("");}
const int N=100005;
ll sz[N];
int f[N],ans[N],fa[N];
pair<int,pair<int,int> > e[N];
inline int gf(int x){
	return fa[x]==x?x:fa[x]=gf(fa[x]);
}
signed main(){
	int n=read(),m=read();
	for(int i=1;i<=n;i++)sz[fa[i]=i]=read();
	for(int i=1;i<=m;i++){
		int s=read(),t=read(),w=read();
		e[i]=mp(w,mp(s,t));
	}
	sort(&e[1],&e[m+1]);
	int cnt=0;
	for(int i=1;i<=m;i++){
		int s=e[i].second.first,t=e[i].second.second,w=e[i].first;
		int tx=gf(s),ty=gf(t);
		if(tx==ty){if(sz[tx]<w){f[tx]++;cnt++;} continue;}
		fa[tx]=ty; sz[ty]+=sz[tx]; f[ty]+=f[tx]; f[ty]++; cnt++; //cout<<sz[ty]<<" "<<cnt<<endl;
		if(sz[ty]>=w){cnt-=f[ty]; f[ty]=0;}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsinged long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
const int inf=1039074182;
using namespace std;
int n;
int a[100005];
bool b[100005];
int m;
int l[100005];
int r[100005];
vector <int> lsh;
vector <pii> vec[100005];
int visit[100005];
vector <int> res;

void dfs(int x)
{
	visit[x]=1;
	for(auto u:vec[x])
	{
		if(visit[u.first]) continue;
		dfs(u.first);
		if(b[u.first])
		{
			res.push_back(u.second);
			b[u.first]^=1;
			b[x]^=1;
		}
	}
}

int main()
{
//	freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	vector <pair<int,int> > psort;
//	psort.reserve(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
		psort.push_back(mp(a[i],b[i]));
		lsh.push_back(a[i]);
	}
	sort(all(psort));
	for(int i=0;i<n;i++)
	{
		a[i]=psort[i].first;
		b[i]=psort[i].second;
	}
	for(int i=n;i>=0;i--)
	{
		b[i]^=(i?b[i-1]:0);
	}
	sort(all(lsh));
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		x=lower_bound(all(lsh),x)-lsh.begin();
		y=upper_bound(all(lsh),y)-lsh.begin();
		vec[x].push_back(mp(y,i));
		vec[y].push_back(mp(x,i));
	}
	for(int i=n;i>=0;i--)
	{
		if(visit[i]) continue;
		dfs(i);
		if(b[i])
		{
//			assert(i!=n);
			over(-1);
		}
	}
	sort(all(res));
	cout<<res.size()<<endl;
	for(auto x:res)
	{
		cout<<x+1<<' ';
	}
	cout<<endl;
	return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}


   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

string s, t;
const ll MAX_str = 3e3;
ll dp[MAX_str + 1][MAX_str + 1] = {};
string dp1[MAX_str+1] = {};
string dp2[MAX_str+1] = {};
int main(){
  cin >> s >> t;
  REP(i, s.size()){
    REP(j, t.size()+1) {
      dp1[j] = dp2[j];
      dp2[j] = "";
    }
    REP(j, t.size()){
      if (dp2[j].size() > dp1[j+1].size()) dp2[j+1] = dp2[j];
      else dp2[j+1] = dp1[j+1];
      if (s[i] == t[j] && dp1[j].size() + 1 > dp2[j+1].size()){
        dp2[j+1] = dp1[j] + s[i];
      }
//      printf("s = %s, t = %s : dp2[%lld] = %s\n", s.substr(0, i + 1).c_str(), t.substr(0, j + 1).c_str(),j+1, dp2[j+1].c_str());
    }
  }
  cout << dp2[t.size()] << endl;
}


Measured memory_bytes: 8320
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <numeric>
#include <iomanip>
#define ll long long
#define pi 3.14159265358979323846
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};
/*
 vector<vector<ll>> g(n+1);
    for(ll i = 0; i < m; i++){
        ll a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll> dist(n+1, -1);
    queue<ll> que;
    que.push(1);
    dist[1] = 0;
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(ll nv : g[v]){
            if(dist[nv]!=-1) continue;
            dist[nv] = dist[v]+1;
            que.push(nv);
        }
    }
*/

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    string s;
    for(ll i = 0; i < c-a; i++)
        s+='R';
    for(ll i = 0; i < d-b; i++)
        s+='U';
    for(ll i = 0; i < c-a; i++)
        s+='L';
    for(ll i = 0; i < d-b+1; i++)
        s+='D';
    for(ll i = 0; i < c-a+1; i++)
        s+='R';
    for(ll i = 0; i < d-b+1; i++)
        s+='U';
    s+="LU";
    for(ll i = 0; i < c-a+1; i++)
        s+='L';
    for(ll i = 0; i < d-b+1; i++)
        s+='D';
    s+='R';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
DATA = input().split()
RESULT = []

for datum in DATA:
    if datum in ["+", "-", "*"]:
        b = RESULT.pop()
        a = RESULT.pop()
        if datum == "+":
            RESULT.append(a+b)
        elif datum == "-":
            RESULT.append(a-b)
        else:
            RESULT.append(a*b)
    
    else:
        RESULT.append(int(datum))
        
print(RESULT[0])



Measured memory_bytes: 5600
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

typedef struct edge_t{
    int v, next;
    long int w;
}edge_t;
edge_t edges[200005];
int head[100005];
int ptr;
typedef pair<long int, int> edgedist_t;
priority_queue<edgedist_t, vector<edgedist_t>, greater<edgedist_t> > Q;
long int dist[100005] = {-1};
bool vis[100005] = {false};

void addedge(int u, int v, long int cost){
    edges[ptr].v = v;
    edges[ptr].w=cost;
    edges[ptr].next=head[u];
    head[u]=ptr++;
}

int bfs(int start){
    dist[start]=0;
    Q.push(edgedist_t(0, start));
    while(!Q.empty()){
        const edgedist_t p = Q.top();
        Q.pop();
        int u = p.second;
        vis[u]=true;
        for(int e = head[u]; e!=0; e = edges[e].next){
            int v = edges[e].v;
            if(vis[v]) continue;
            long int cost = edges[e].w;
            if(dist[v]==-1 || (dist[v]!=-1 && dist[v]>dist[u]+cost)){
                dist[v] = dist[u]+cost;
                Q.push(edgedist_t(dist[v], v));
            }
        }
    }
    return 0;
}


int main(){
    int N, a, b, c, Q, K, x, y;
    scanf("%d", &N);
    ptr=1;
    for(int i=1; i<N; i++){
        scanf("%d%d%d", &a, &b, &c);
        addedge(a, b, c);
        addedge(b, a, c);
    }
    fill(dist, dist+100005, -1);
    scanf("%d%d", &Q, &K);
    bfs(K);
    while(Q--){
        scanf("%d%d", &x, &y);
        printf("%ld\n", dist[x]+dist[y]);
    }
    return 0;
}

Measured memory_bytes: 7408
//agc010_a.cpp
//Sat Oct 27 11:57:35 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int oddnum = 0;
	for (int i=0;i<n;i++){
		int temp;
		cin >> temp;
		if (temp%2 == 1){
			oddnum++;
		}
	}

	if (oddnum%2==1){
		cout << "NO" << endl;
	}else {
		cout << "YES" << endl;
	}


}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ri = lambda: int(input())
rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N=ri()
SP = []
for i in range(1,N+1):
    s,p = rl()
    SP.append([s,p,i])

SP.sort(key=lambda x: (x[0],-x[1]))
for s,p,i in SP:
    print(i)

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

int main()
{
	string a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	string cs = a + b + f + e + a + b + f + e;
	string ds = e + f + b + a + e + f + b + a;
	string as = b + c + e + d + b + c + e + d;
	string fs = d + e + c + b + d + e + c + b;
	string bs = a + d + f + c + a + d + f + c;
	string es = c + f + d + a + c + f + d + a;
	
	

	int q;
	string top, front;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		cin >> top >> front;
		string situation = top + front;
		if (cs.find(situation, 0) < cs.size()) cout << c << endl;
		if (ds.find(situation, 0) < ds.size()) cout << d << endl;
		if (as.find(situation, 0) < as.size()) cout << a << endl;
		if (fs.find(situation, 0) < fs.size()) cout << f << endl;
		if (bs.find(situation, 0) < bs.size()) cout << b << endl;
		if (es.find(situation, 0) < es.size()) cout << e << endl;
	}

}


Measured memory_bytes: 3176
n = int(input())
INF = 987456325585
arr  = [int(x) for x in input().split()]

# dp[i][j] -> array is left with elements from index i to j, contains max of x-y if player x starts from here

# dp[0][n-1] -> res

dp = []
for i in range(n):
    dp.append([-INF]*n)

for i in range(n-1,-1,-1):
    for j in range(i,n):
        if i == j:
            dp[i][j] = arr[i]
            continue
        dp[i][j] = max(arr[i] - dp[i+1][j], arr[j] - dp[i][j-1])

print(dp[0][n-1])


Measured memory_bytes: 111964
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;  cin >> n;
  int a[n];
  int ma= -200;
  int mi = 200;
  for(int i=0 ; i<n ; i++){
    cin >> a[i];
    mi = min(mi,a[i]);
    ma = max(ma, a[i]);
  }
  long long ans = 1e10;
  for(int i=mi ; i<=ma ; i++){
    long long  sum = 0;
    for(int j=0 ; j<n ; j++){
      sum += (i-a[j])*(i-a[j]);
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	set<int>st;
	For(i,n){
		int n;
		cin>>n;
		st.insert(n);
	}
	int ans=0;
	for(int i=1;i<=100;i++){
		if(st.count(i))ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static int[] preNum, parent, lowest;
        static bool[] visited;
        static int timer;

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int V = int.Parse(input[0]);
            int E = int.Parse(input[1]);

            Dictionary<int, List<int>> G = new Dictionary<int, List<int>>();
            for (int i = 0; i < V; i++) G.Add(i, new List<int>());

            for (int i = 0; i < E; i++)
            {
                input = Console.ReadLine().Split(' ');
                int s = int.Parse(input[0]);
                int t = int.Parse(input[1]);

                G[s].Add(t);
                G[t].Add(s);
            }

            PrintBridges(G, V);
        }

        static void PrintBridges(Dictionary<int, List<int>> G, int V)
        {
            preNum = new int[V];
            parent = new int[V];
            lowest = new int[V];
            visited = new bool[V];
            timer = 1;

            DFS(G, 0, -1);

            List<KeyValuePair<int, int>> ans = new List<KeyValuePair<int, int>>();
            for (int i = 1; i < V; i++)
            {
                int p = parent[i];

                if (preNum[p] < lowest[i])
                {
                    if (p < i) ans.Add(new KeyValuePair<int, int>(p, i));
                    else ans.Add(new KeyValuePair<int, int>(i, p));
                }
            }
            var query = ans.OrderBy(a => a.Key).ThenBy(a => a.Value);

            StringBuilder sb = new StringBuilder();
            foreach (var q in query) sb.AppendLine(q.Key + " " + q.Value);
            Console.Write(sb);
        }

        static void DFS(Dictionary<int, List<int>> G, int cur, int prev)
        {
            preNum[cur] = lowest[cur] = timer;
            timer++;

            visited[cur] = true;

            for (int i = 0; i < G[cur].Count; i++)
            {
                int next = G[cur][i];

                if (!visited[next])
                {
                    parent[next] = cur;

                    DFS(G, next, cur);

                    lowest[cur] = Math.Min(lowest[cur], lowest[next]);
                }
                else if (next != prev)
                {
                    lowest[cur] = Math.Min(lowest[cur], preNum[next]);
                }
            }
        }
    }
}

Measured memory_bytes: 13500
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        a: usize, b: usize, c: usize,
    }
    let ans = if a-b > c {
        0
    } else {
        c - (a-b)
    };
    println!("{}", ans);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> q(N);
  vector<int> ans(N,0);
  int M = 0;
  for (int &e : q) cin >> e;
  for (int i = N; i > 0; i--) {
    int p = N/i;
    int sum = 0;
    for (int j = 2; j <= p; j++) sum += ans[i*j-1];
    if (sum % 2 != q[i-1]) {
      ans[i-1] = 1;
      M += 1;
    }
  }
  cout << M << endl;
  for (int i = 0; i < N; i++) {
    if (ans[i] == 1) {
      M -= 1;
      cout << i+1 << (M == 0 ? "\n" : " "); 
    }
  }
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}
int main(){
    long long a,b; cin >> a >> b;
    cout << bitset<32>(a&b) << endl;
    cout << bitset<32>(a|b) << endl;
    cout << bitset<32>(a^b) << endl;
}
  




Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
int main(int argc, char *argv[])
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<" ";
	if(a+b>=n)
		cout<<a+b-n<<endl;
	else
		cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
 using namespace std;
 int main()
{
  int x,y;
  cin >> x >> y;
  while(x!=0 || y!=0)
  {
    if (x > y)
       cout << y << " " << x <<endl;
    else
       cout << x << " " << y <<endl;
    cin >> x >> y;
  }
  return 0;
}
    

Measured memory_bytes: 1160
from sys import stdin
from statistics import median
n = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
bi = [x -( i +1) for i,x in enumerate(a)]
b = median(bi)
s = 0
i = 0
while i < n:
    s += abs(bi[i] - b)
    i = i+1
print(int(s))


Measured memory_bytes: 27240
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	hs := make([]int,n)
	for i := 0; i < n; i++ {
		var h int
		fmt.Scan(&h)
		hs[i] = h
	}

	count := 0
	LABEL:
	for i := 0; i < n; i++ {
		for j := 0; j < i; j++ {
			if hs[i] < hs[j] {
				continue LABEL
			}
		}
		count++
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    int sum = 0;
    rep(i, N){
        cin >> A[i];
        sum ^= A[i];
    } 
    rep(i, N){
        cout << (sum ^ A[i]) << ' '; 
    }
    cout << endl;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 3000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =    1e9+7;
ll n;
double sum;
ll x[10],y[10];
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

cin>>n;
rep(i,1,n+1)
{
	cin>>x[i]>>y[i];
}
rep(i,1,n+1)
{
	rep(j,1,i)
	sum+=1.0*(sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])))*2.0;
}cout<<setprecision(10)<<sum/n;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define il inline
#define stt static
#define rg register
#define ll long long
#define db double
#define pii pair<int,int>
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define y1 substitute_of_y1
#define DEBUG(x) cerr<<#x" = "<<x<<endl;
using namespace std;

template<typename T> il T rd(){
	T nmb=0;int sgn=0;char chr=getchar();
	while(!isdigit(chr)){if(chr=='-')sgn=1;chr=getchar();}
	while(isdigit(chr)){nmb=(nmb<<3)+(nmb<<1)+chr-'0';chr=getchar();}
	return sgn?-nmb:nmb;
}
template<typename T> void wt(T nmb){
	if(nmb>9)wt(nmb/10);
	putchar(nmb%10+'0');
}
template<typename T> il void cmax(T &x,T y){x=x>y?x:y;}
template<typename T> il void cmin(T &x,T y){x=x<y?x:y;}
inline void proc_status(){
	ifstream t ("/proc/self/status");
	cerr<<string(istreambuf_iterator<char>(t),istreambuf_iterator<char>())<<endl;
	/*freopen("/proc/self/status","r",stdin);
	char ch[100];
	while(scanf("%s",ch)!=EOF)cerr<<ch<<endl;*/
}

const int N=2e5+10,L=20;

int a[N];

vector<pii>vec[L];

#define lowbit(x) (x&(-x))

int f[N<<1],g[N<<1];

int ans[N],b[N];

int main(){
	int n=rd<int>(),p=rd<int>();
	for(int i=1;i<=n;++i)a[i]=rd<int>();
	int lev=1;
	int Flg=0;
	for(int k=p;!Flg;k>>=1,++lev){
		if(!k)Flg=1;
		for(int l=1,r=1;l<=n;l=r+1){
			r=l;
			while(r<n&&a[r+1]-a[r]<=k)++r;
			vec[lev].pb(mp(l,r));
		}
	}
	lev-=2;
	int k=(1<<lev)-1;
	for(int S=0;S<=k;++S)f[S]=0,g[S]=n+1;
	for(int S=0;S<=k;++S){
		for(int T=S;T;T^=lowbit(T)){
			int t=(int)log2(lowbit(T))+2;
			int U=S^lowbit(T);
			int pos=upper_bound(vec[t].begin(),vec[t].end(),mp(f[U]+1,n+1))-vec[t].begin()-1;
			if(pos>=0)cmax(f[S],vec[t][pos].snd);
			pos=upper_bound(vec[t].begin(),vec[t].end(),mp(g[U]-1,n+1))-vec[t].begin()-1;
			if(pos>=0&&vec[t][pos].snd>=g[U]-1)cmin(g[S],vec[t][pos].fst);
		}
	}
	for(int S=0;S<=k;++S){
		int l=f[S],r=g[k^S];
		int pos1=upper_bound(vec[1].begin(),vec[1].end(),mp(l+1,n+1))-vec[1].begin()-1;
		int pos2=upper_bound(vec[1].begin(),vec[1].end(),mp(r-1,n+1))-vec[1].begin()-1;
		if(vec[1][pos2].snd<r-1)++pos2;
		if(pos1>=0&&pos2>=0&&pos1>pos2){
			for(int i=1;i<=n;++i)puts("Possible");
			return 0;
		}
		if(pos1>=0&&pos2>=0&&pos1==pos2)b[pos1]=1;
	}
	for(int i=0;i<(int)vec[1].size();++i)
		for(int t=vec[1][i].fst;t<=vec[1][i].snd;++t)
			ans[t]=b[i];
	for(int i=1;i<=n;++i)
		if(ans[i])puts("Possible");
		else puts("Impossible");
	return 0;
}

Measured memory_bytes: 9584
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
	int n, x;
	cin >> n >> x;
	vector<int> m(n);
	int sum = 0;
	for (int i=0; i < n; i++)
	{
		cin >> m.at(i);
		
	}
	sort(m.begin(), m.end());
	for (int i = 0; i < n; i++)
	{
		sum += m.at(i);
		if (sum > x)
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << n + (x - sum) / m.at(0) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define uLL unsigned long long
#define db long double

using namespace std;
const int N=3e5+10;
int rd()
{
	int x=0,w=1;char ch=0;
	while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return x*w;
}
struct line
{
	int l,r;
	bool operator < (const line &bb) const {return r-l+1<bb.r-bb.l+1;}
}a[N];
int n,m,bt[N];
void add(int x,int y){while(x<=n) bt[x]+=y,x+=x&(-x);}
int gsm(int x){int an=0;while(x) an+=bt[x],x-=x&(-x);return an;}

int main()
{
	m=rd(),n=rd();
	for(int i=1;i<=m;++i) a[i].l=rd(),a[i].r=rd();
	sort(a+1,a+m+1);
	for(int i=1,j=1;i<=n;++i)
	{
		while(j<=m&&a[j].r-a[j].l+1<=i)
			add(a[j].l,1),add(a[j].r+1,-1),++j;
		int ans=m-j+1;
		for(int d=i;d<=n;d+=i) ans+=gsm(d);
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 3712
# Papers, Please
N = int(input())
A = list(map(int, input().split()))
ans = 'APPROVED'
for a in A:
    if a % 2 == 0:
        if (a % 3 != 0) & (a % 5 != 0):
            ans = 'DENIED'
            break
        else:
            continue
    else:
        continue
print(ans)

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

#define int long long
#define MAXN 100005

int n,m,ans;
int a[MAXN];

signed main()
{
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	for(int i = 1; i <= n; i ++)
		for(int j = i+1; j <= n; j ++)
			ans += a[i]*a[j];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256