akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
    int N, a[100];
    cin >> N;
    double sum = 0;
    REP(i, N) {
        cin >> a[i];
        sum += a[i];
    }
    double a_mean = sum / N;
    int ans = INF;
    double min_ans = INF;
    REP(i, N) {
        if (abs(a_mean - a[i]) < min_ans) {
            ans = i;
            min_ans = abs(a_mean - a[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100


int main()
{
  int B[N],i,j,n,cnt=0,minj,temp;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      scanf("%d",&B[i]);
    }

  
   for(i=0;i<n;i++)
    {
      minj = i;
      for(j=i;j<n;j++)
	{
	  if(B[j] < B[minj])
	    {
	      minj = j;

	      temp = B[i];
	      
	      
	    }
	}
      if(minj != i)
	{
	   B[i] = B[minj];
	   B[minj] = temp;
           cnt++;
	}
    }

   for(i=0;i<n;i++)
     {
       printf("%d",B[i]);
       if(i!=n-1)printf(" ");
     }
   printf("\n%d\n",cnt);
  
  return 0;
}




Measured memory_bytes: 2100
#include <iostream>
using namespace std;
int main(void){
    int N;
    double ret;
    cin >> N;
    
    if(N % 2 == 1){
        ret = (double)(N/2 + 1) / (double)N;
    }
    else
    {
        ret = 0.5;
    }
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

int a, b, n;
int under_construction[16][16];
ll dp[16][16];
int dx[2] = {0, 1};
int dy[2] = {1, 0};

ll solve(){
	// printf("solve() called\n");
	for(int i = 0; i < a; i++){
		for(int j = 0; j < b; j++){
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;


	for(int i = 0; i < a; i++){
		for(int j = 0; j < b; j++){
			// printf("dp[%d][%d] = %d\n", i+1, j+1, dp[i][j] );
			// printf("under_construction[%d][%d] = %d\n", i+1, j+1, under_construction[i][j]);
			for(int k = 0; k < 2; k++){
				int nx = i + dx[k], ny = j + dy[k];
				if(nx < a and ny < b and not under_construction[nx][ny]){
					dp[nx][ny] += dp[i][j];
				}
			}
		}
	}

	return dp[a-1][b-1];
}

int main(void){
	while(scanf("%d%d", &a, &b) != EOF){
		if(a==0 and b==0) break;
		for(int i = 0; i < a; i++){
			for(int j = 0; j < b; j++){
				under_construction[i][j] = false;
			}
		}
		scanf("%d", &n);
		for(int i = 0; i < n; i++){
			int x, y; scanf("%d%d", &x, &y);
			under_construction[--x][--y] = true;
		}

		printf("%lld\n", solve());
	}

	return 0;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define open freopen(input.txt,"r",stdin); freopen(output.txt,"w",stdout);
#define precise(t) cout << fixed << setprecision(t)
#define forr(i,n) for(int i(0);i<n;++i)
#define repup(i,a,b) for(int i(a); i <=b; ++i)
#define repdown(i,a,b) for(int i(a);i>=b;i--)
#define testcase(t) int t; cin >> t; wl(t)
#define input(n) int n; cin >> n;
#define sz(a) int((a).size())
#define pb push_back
#define pf push_front
#define mp make_pair
#define ff first
#define ss second
#define bb begin()
#define ee end()
#define all(c) c.bb, c.ee
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a), (b))
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef map<char,int> mci;
typedef pair<int, int> pii;
typedef map<int,pii> ipii;

const int inf = INT_MAX; 
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;

/*
int main(){
	char arr[4];
	forr(i,4) {cin >> arr[i];}
	sort(arr,arr+4);
	if(arr[0]==arr[1] && arr[2]==arr[3]){
		cout << "Yes";
	}
	else{
		cout << "No";
	}

}*/

int main(){

	int n;
	cin >> n;
	int hf=(n/2);
	int arr[n];
	forr(i,n) cin >> arr[i];
	sort(arr,arr+n);
	int a=arr[hf];
	int b=arr[hf-1];
	if(a==b){
		cout << 0 ;
	}
	else{
		cout << a-b;
	}


}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    int n;
    int x[8], y[8], v[8];
    double ans = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    for(int i=0;i<n;i++){
        v[i] = i;
    }
    do{
        int px = x[v[0]], py = y[v[0]];
        for(int i=1;i<n;i++){
            int nx = x[v[i]];
            int ny = y[v[i]];
            ans += sqrt((double)(nx-px) * (nx-px) + (ny-py) * (ny-py));
        }
    }while(next_permutation(v, v+n));
    for(int i=1;i<=n;i++){
        ans /= i;
    }
    cout << fixed << setprecision(16) << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(string, s);
    int ans = 0;
    for(int i = 0; i < (int)s.size()-1; i ++){
        //Cout(i, " ", s);
        if(s[i] != s[i+1]){
            auto itr = s.begin() + i;
            s.erase(itr, itr + 2);
            ans ++;
            if(i > 0) i --;
            i --;
        }
    }
    
    Cout(2*ans);
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
#define ch() getchar()
#define pc(x) putchar(x)
template<typename T>inline void read(T&x){
	int f;char c;
	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;
	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;
}
template<typename T>inline void write(T x){
	static char q[64];int cnt=0;
	if(!x)pc('0');if(x<0)pc('-'),x=-x;
	while(x)q[cnt++]=x%10+'0',x/=10;
	while(cnt--)pc(q[cnt]);
}
int main(){
	int A,B,C,K,ans=0;
	read(A),read(B),read(C),read(K);
	if(K<=A)ans+=K;
	else{
		ans+=A,K-=A;
		if(K<=B)ans+=0;
		else{
			ans+=0,K-=B;
			ans-=K;
		}
	}
	write(ans);
	return 0;
}


Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<string> svec;

int main(){
    ll n,k=0,ans=0;
    cin>>n;
    lvec p(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
    }
    while(k<n-1){
        if(p[k]!=k&&p[k+1]!=k+1){
            k+=2;
        }else if(p[k]==k&&p[k+1]==k+1){
            swap(p[k],p[k+1]);
            ans++;
            k+=2;
        }else if(p[k]==k){
            swap(p[k],p[k+1]);
            ans++;
            k+=2;
        }else if(p[k+1]==k+1){
            k++;
        }
    }
    if(k==n-1){
        if(p[n-1]==n-1||p[n-2]==n-2) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int A,B,C; cin >> A >> B >> C;
    int k = 1;
    REP(i,B) {
        if((A%B)*(k%B)%B == C) {
            cout << "YES" << endl;
            return 0;
        } else ++k;
    }
    cout << "NO"  << endl;
}

Measured memory_bytes: 3620
/*
チェスボードの描画
*/

#include<stdio.h>
int main(void){
  int h,w;/*チェスボードの縦、横の長さ*/
  int i,j;

  while(1){
    scanf("%d %d",&h,&w);
    if(h == 0 && w == 0)
      break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if((i+j)%2 == 0)
	  printf("#");
	else
	  printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}
      


Measured memory_bytes: 2624
# E - Active Infants
N = int(input())
A = list(map(int,input().split()))
dp = [[] for _ in range(N+1)]
dp[0].append(0)
for i in range(N):
    A[i] = [A[i],i+1]
A.sort(reverse=True)
for M in range(1,N+1):
    Ai,i = A[M-1]
    # x=0
    dp[M].append(dp[M-1][0]+Ai*(N-(M-1)-i))
    # 1<=x<=M-1
    for x in range(1,M):
        dp[M].append(max(dp[M-1][x-1]+Ai*(i-x),dp[M-1][x]+Ai*(N-(M-x-1)-i)))
    # x=M
    dp[M].append(dp[M-1][M-1]+Ai*(i-M))
print(max(dp[N]))

Measured memory_bytes: 109992
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    cnt = defaultdict(int)
    for i in range(1, N + 1):
        cnt[i % K] += 1

    ret = 0
    for a in range(K):
        b = (K - a) % K
        c = (K - a) % K
        if (b + c) % K != 0: continue
        ret += cnt[a] * cnt[b] * cnt[c]
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27020
import sys
input = sys.stdin.readline

n, q = map(int, input().split())
s = str(input())
ac = [0] * n
for i in range(1, n):
    ac[i] = ac[i-1]
    if(s[i-1] == "A" and s[i] == "C"):
        ac[i] += 1
for i in range(q):
    l, r = map(int, input().split())
    print(ac[r-1] - ac[l-1])

Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
string s;
bool two;
ll ans;
vector<string> he;
//ll a[200005];

//ll const BAD = 1e9+7;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> s;
	n = s.length();
	string z = to_string(s[0]);
	he.push_back(z);
	for (ll i = 1; i < n; i++){
		string x = to_string(s[i]);
		if(x == he[he.size()-1]){
			if (i == n-1){//the reason why we can do this is that we are just adding the last char to the last element of the vector
              
				cout << he.size();
				return 0;
				}
			string a = to_string(s[i]);
			string b = to_string(s[i+1]);
			string c = a+b;
			he.push_back(c);
			i += 1;			}
		else{
			he.push_back(x);
			
			}
		}
		
			cout << he.size();
}


Measured memory_bytes: 11016
import sys,itertools as it
f=sys.stdin.readline
n=int(f())
ll=[]
for i in range(n):
  a=int(f())
  for _ in range(a):
    x,y=map(int,f().split())
    ll+=[(i,x-1,y)]
c=0
for p in it.product([0,1],repeat=n):
  if all(p[i]<1 or p[x]==y for i,x,y in ll):
    c=max(c,sum(p))
print(c)

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second

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

    int n;
    cin >> n;
    vi v(n);
    for(auto &z : v)
        cin >> z;

    sort(rall(v));
    ll ans = 0LL;
    vector<ll> b;
    for(int i = 0; i < n; ++i)
    {
        b.pb(v[i]);
        if(i)
            b.pb(v[i]);
    }

    for(int i = 0; i < n-1; ++i)
        ans += b[i];
    cout << ans << '\n';
}


Measured memory_bytes: 8220
length = int(input())
li = list(input())
li2 = []
i = -1
for str in li[:]:
    i = 1 + i
    if i + 1 == len(li):
        li2.append(li[i])
        print(len(li2))
        break
    if li[i] != li[i + 1]:
        li2.append(li[i])
        continue

Measured memory_bytes: 5416
#include <iostream>

using namespace std;

int main()
{

    int N, A, B ;
    cin >> N ;
    if (N==1)
        cout << "Hello World" ;
    else if (N==2)
        {cin >> A>> B ;
    int e ;
    e=A+B ;
    cout << e;}

    return 0;
}


Measured memory_bytes: 256
fn main() {
    let n: usize = read();
    let a: Vec<usize> = read_vec();
    let mut ball: Vec<bool> = vec![false;n];
    for i in (1..n+1).rev() {
        let mut f = false;
        let mut m = i;
        loop {
            m += i; if m > n { break; }
            f ^= ball[m-1];
        }
        ball[i-1] = f ^ (a[i-1] == 1);
    }
    let mut ans: Vec<usize> = vec![];
    for (i,b) in ball.iter().enumerate() {
        if *b { ans.push(i+1); }
    }
    println!("{}", ans.len() );
    for i in ans.iter() {
        print!("{} ", *i);
    }
}

fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_owned()
}

fn read<T: std::str::FromStr>() -> T{
    get_line().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T>{
    get_line().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n,t; cin >> n >> t;
  int a0,a1; cin >> a0;
  int sum = 0;
  rep(i,n-1){
    cin >> a1;
    if(a1-a0 >=t) sum += t;
    else sum += (a1 - a0);
    a0 = a1;
  }
  sum += t;
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< vector< int > > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;
#define VT( T ) vector< T >
#define VVT( T ) vector< vector< T > >
#define LIM( T ) numeric_limits< T >

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) ( c ).begin(), ( c ).end()
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + p, ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

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

	for ( int K; cin >> K && K; )
	{
		string S, T;
		cin >> S >> T;

		VI a, b;
		transform( ALL( S ), BI( a ), bind( minus< int >(), _1, '0' ) );
		transform( ALL( T ), BI( b ), bind( minus< int >(), _1, '0' ) );

		VI c;
		transform( ALL( a ), b.begin(), BI( c ), []( const int x, const int y ){ return ( y - x + 10 ) % 10; } );
		c.PB( 0 );

		VI ds;
		adjacent_difference( ALL( c ), BI( ds ) );
		transform( ALL( ds ), ds.begin(), []( const int d ){ return ( d + 10 ) % 10; } );
		ds.erase( remove( ALL( ds ), 0 ), ds.end() );
		sort( ALL( ds ) );

		int res = SZ( ds );
		do
		{
			VI csum;
			partial_sum( ALL( ds ), BI( csum ) );
			res = min< int >( res, SZ( ds ) - count_if( ALL( csum ), []( const int x ){ return x % 10 == 0; } ) );
		}
		while ( next_permutation( ALL( ds ) ) );

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <cassert>
#pragma GCC optimize("O3")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

int main() {
    int k;
    cin >> k;
    if (k % 2) {
        cout << (k / 2) * ((k + 1) / 2) << endl;
    } else {
        cout << (k / 2) * (k / 2) << endl;
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		StringBuilder sb = new StringBuilder();
		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int k = Integer.parseInt(line);
			if (k == 0) {
				break;
			}
			int sum = 0;
			StringTokenizer st = new StringTokenizer(br.readLine());
			while (st.hasMoreTokens()) {
				sum += Integer.parseInt(st.nextToken());
			}
			sb.append(sum / (k - 1)).append('\n');
		}
		System.out.print(sb.toString());
	}
}

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

#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

const double PI = 3.14;


int main()
{

	uint64_t a;
	cin >> a;

	struct obj
	{
		int actTime = 0;
		int limit = 0;
	};

	vector< obj > vec( a );

	for( int i=0 ; i<a ; i++ )
	{
		cin >> vec[i].actTime >> vec[i].limit;
	}

	sort( vec.begin(), vec.end(), []( const obj &a, const obj &b ){ return a.limit < b.limit; } );


	uint64_t now = 0;
	bool ok = true;

	for( auto &it : vec )
	{
		now += it.actTime;

		if( now > it.limit )
		{
			ok = false;
			break;
		}
	}

		
	cout << ( ok ? "Yes" : "No" ) << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

bool mycmp(ii a, ii b) {
	return a.second > b.second;
}

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

	int n, m;
	scanf("%d%d", &n, &m);
	vi a(n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(all(a));

	vector<ii> op(m);
	for (int i = 0; i < m; i++) scanf("%d%d", &op[i].first, &op[i].second);
	sort(all(op), mycmp);

	int rep = 0;
	for (int i = 0; i < m && rep < n; i++) {
		if (op[i].second <= a[rep]) break;
		int x = lower_bound(a.begin() + rep, a.end(), op[i].second) - a.begin();
		x = min(x, rep + op[i].first);
		for (; rep < x; rep++) a[rep] = op[i].second;
	}

	long long ans = 0;
	for (int x : a) ans += x;
	printf("%lld\n", ans);
}


Measured memory_bytes: 1408
use std::io::Read;

fn update_min<T: Ord>(x: &mut T, min: T){
    if *x > min {
        *x = min;
    }
}

fn lower_bound<T: Ord>(a: &Vec<T>, x: T) -> usize {
    match a.binary_search(&x) {
        Ok(i) => i,
        Err(i) => i
    }
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();
    let q: usize = iter.next().unwrap().parse().unwrap();
    let s: Vec<i64> = (0..a).map(|_| iter.next().unwrap().parse().unwrap()).collect();
    let t: Vec<i64> = (0..b).map(|_| iter.next().unwrap().parse().unwrap()).collect();

    for _ in 0..q {
        let x: i64 = iter.next().unwrap().parse().unwrap();
        let p = lower_bound(&s, x) as i32;
        let q = lower_bound(&t, x) as i32;

        let mut ans = std::i64::MAX;

        for i in p-2..p+3 {
            if i < 0 || i >= a as i32 { continue; }
            let di = s[i as usize];
            for j in q-2..q+3 {
                if j < 0 || j >= b as i32 { continue; }
                let dj = t[j as usize];
                update_min(&mut ans, (x-di).abs()+(di-dj).abs());
                update_min(&mut ans, (x-dj).abs()+(di-dj).abs());
            }
        }

        println!("{}", ans);
    }

}


Measured memory_bytes: 12920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int N, A, B, C;
vector<int> L;

int dfs(int cnt, int a, int b, int c) {
    if (cnt == N) {
        if (a == 0 || b == 0 || c == 0) return 1000000010;
        return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    }

    int sum0 = dfs(cnt + 1, a, b, c);
    int sum1 = dfs(cnt + 1, a + L[cnt], b, c) + 10;
    int sum2 = dfs(cnt + 1, a, b + L[cnt], c) + 10;
    int sum3 = dfs(cnt + 1, a, b, c + L[cnt]) + 10;

    int min1 = min(sum0, sum1);
    int min2 = min(sum2, sum3);
    int min3 = min(min1, min2);
    return min3;
}

int main() {
    cin >> N >> A >> B >> C;
    L.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }

    cout << dfs(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
# 070 B 
A,B,C,D= map(int,input().split())
if B < C:
    print(0)
    exit()
if D < A:
    print(0)
    exit()
if A <= C:
    start =C
else:
    start =A
if B <=D:
    end =B
else:
    end =D
print(end-start)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
    long long a,b,c,d;
    cin>> a >> b >> c >> d;
    long long t1,t2,t3,t4;
    t1 = a*c;
    t2 = a*d;
    t3 = b*c;
    t4 = b*d;
    long long ans;
    ans = t1;
    ans = max(ans,t2);
    ans = max(ans,t3);
    ans = max(ans,t4);
    cout << ans << endl;
}



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

using namespace std;

vector<int> primesWithRem[5];
vector<int> primes;

int main()
{
    int N;

    for (int i = 2; i <= 55'555; i++)
    {
        bool isPrime = true;
        for (const int &p : primes)
        {
            if (i % p == 0)
            {
                isPrime = false;
            }
        }
        if (isPrime)
        {
            primes.push_back(i);
            primesWithRem[i % 5].push_back(i);
        }
    }

    int idx = 1;
    for (int i = 1; i < 5; i++)
    {
        if (primesWithRem[idx].size() < primesWithRem[i].size())
        {
            idx = i;
        }
    }

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cout << primesWithRem[idx].at(i) << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ll long long
#define ld long double
const int N=2e5;
int idx[N+5];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int i,t;
    int d=0;
    vector<int> b,a;
    for(i=0;i<n;i++)
    {
        scanf("%d",&t);
        idx[t]++;
        if(idx[t]==1)
        {
            d++;
            b.pb(t);
        }
    }
    for(auto it:b)
    {
        a.pb(idx[it]);
    }
    sort(a.begin(),a.end());
    int ans=0;
    if(d>k)
    {
        for(auto it:a)
        {
            ans+=it;
            d--;
            if(d==k)
            {
                break;
            }
        }
    }
    printf("%d",ans);
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.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;}
ll mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  vll a(n), b(n), c(n);
  rep(i, 0, n) cin >> a.at(i) >> b.at(i) >> c.at(i);
  vvll dp(n + 1, vll(3, 0));
  rep(i, 1, n + 1){
    dp.at(i).at(0) = a.at(i - 1) + max(dp.at(i - 1).at(1), dp.at(i - 1).at(2));
    dp.at(i).at(1) = b.at(i - 1) + max(dp.at(i - 1).at(0), dp.at(i - 1).at(2));
    dp.at(i).at(2) = c.at(i - 1) + max(dp.at(i - 1).at(0), dp.at(i - 1).at(1));
  }
  cout << max(dp.at(n).at(0), max(dp.at(n).at(1), dp.at(n).at(2))) << endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)
#define COUT(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

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

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================
// Template End =========================

constexpr int MOD=1e9+7;
locale LOCATE=locale::classic();

int main(void){
  int n; cin>>n; string s; cin>>s;
  if(n%2==1){
    cout<<"No"; return 0;
  }
  Yn(s.substr(0,n/2)==s.substr(n/2,n/2));
}











Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define inf 0x3f3f3f3f

using namespace std;

namespace SETS {

int fa[100005];

void init(int n) {
  for(int i=1;i<=n;i++) fa[i]=i;
}

int find_father(int x) {
  return (fa[x]==x)?x:fa[x]=find_father(fa[x]);
}

void merge(int x,int y) {
  x=find_father(x);y=find_father(y);
  if (x==y) return;
  fa[x]=y;
}

}

int a[100005],b[100005];
vector <int> vt1[200005],vt2[200005];

int calc(int n,int m) {
  SETS::init(n);
  for(int i=1;i<=m;i++) {
  	vt1[i].clear();
  	vt2[i].clear();
  }
  for(int i=1;i<=n;i++) {
  	vt1[a[i]].push_back(i);
  	vt2[b[i]].push_back(i);
  }
  for(int i=1;i<=m;i++) {
  	for(int j=0;j<vt1[i].size();j++) SETS::merge(vt1[i][j],vt2[i][j]);
  	for(int j=1;j<vt1[i].size();j++) SETS::merge(vt1[i][j],vt1[i][j-1]);
  }
  int ans=0;
  for(int i=1;i<=n;i++)
    if (SETS::find_father(i)==i) ans++;
  return n+ans;
}

int num[200005],num2[100005],num3[100005];
int cnt1[200005],cnt2[200005];

int main() {
  int n,s=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
    scanf("%d",&a[i]);
    num[i]=a[i];
    s^=a[i];
  } 
  for(int i=1;i<=n;i++) {
    scanf("%d",&b[i]);
    num[n+i]=b[i];
  }
  int m=2*n;
  sort(num+1,num+m+1);
  int fir=s;
  s=lower_bound(num+1,num+m+1,s)-num;
  if (num[s]!=fir) s=0;
  int pp=0;
  for(int i=1;i<=n;i++)
    if (a[i]!=b[i]) {
    	pp++;
    	num2[pp]=lower_bound(num+1,num+m+1,a[i])-num;
    	num3[pp]=lower_bound(num+1,num+m+1,b[i])-num;
	}
  n=pp;
  for(int i=1;i<=n;i++) {
  	a[i]=num2[i];
  	b[i]=num3[i];
  	cnt1[a[i]]++;
  	cnt2[b[i]]++;
  }
  int diff=0;
  for(int i=1;i<=m;i++)
    if (cnt1[i]!=cnt2[i]) diff+=abs(cnt1[i]-cnt2[i]);
  int ans=inf;
  if (!diff) ans=min(ans,calc(n,m));
  if (diff==2) {
  	int p=0;
  	for(int i=1;i<=n;i++)
  	  if (cnt1[a[i]]>cnt2[a[i]]) p=a[i];
  	for(int i=1;i<=n;i++)
  	  if (b[i]==s&&cnt2[b[i]]>cnt1[b[i]]) {
  	  	  swap(b[i],p);
  	  	  ans=min(ans,calc(n,m)-1);
  	  	  swap(b[i],p);
  	  	  break;
		}
  }
  if (!diff) {
  	for(int i=1;i<=n;i++)
  	  if (s==b[i]) {
  	  	  ans=min(ans,calc(n,m)-1);
  	  	  break;
		}
  }
  printf("%d\n",(ans<inf)?ans:-1);
  return 0;
}

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

void solve() 
{
    int n;cin>>n;
    int d[n];REP(i,n)cin>>d[i];
    sort(d,d+n);
    cout<<d[n/2]-d[n/2-1]<<endl;
}

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

Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int cnt = 0;
		for(int i = 0 ; i < n ; i++) {
			if(sc.nextInt() >= k) {
				cnt++;
			}
		}

		System.out.println(cnt);

	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

	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() {
		if(hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		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 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();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}


Measured memory_bytes: 22996
from math import sqrt
x = int(input())
while x:
    cnt = 0
    for i in range(2, int(sqrt(x)) + 1):
        if x % i != 0:
            cnt += 1
    if cnt == int(sqrt(x)) - 1:
        print(x)
        exit()
    else:
        x += 1

Measured memory_bytes: 3060
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define INF 1000000007
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define CLR(a) memset((a), 0, sizeof(a))

using ll = long long;
using ull = unsigned long long;
using namespace std;

inline int toInt(string s){
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T> inline string toString(T x){
    ostringstream sout;
    sout << x;
    return sout.str();
}

int main(void){

    int n, a, b, c;
    cin >> n >> a >> b >> c;

    int l[n];
    FOR(i,0,n)cin >> l[i];

    //sort(l, l+n);

    int ans = INF;
    FOR(i,0,pow(4,n)){
        int p[n];
        int tmp = i;
        int at=0, bt=0, ct=0;
        int anst = 0;
        FOR(j,0,n){
            p[n-j-1] = tmp/pow(4,(n-j-1));
            tmp %= int(pow(4,(n-j-1)));

            if(p[n-j-1]==1){
                if(at!=0)anst += 10;
                at += l[n-j-1];

            }else if(p[n-j-1]==2){
                if(bt!=0)anst += 10;
                bt += l[n-j-1];

            }else if(p[n-j-1]==3){
                if(ct!=0)anst += 10;
                ct += l[n-j-1];
            }
        }
        anst += abs(at-a)+abs(bt-b)+abs(ct-c);
        if(at!=0 && bt!=0 && ct!=0)ans = min(ans,anst);
        //cout << "anst=" << anst << ", at=" << at << ", bt=" << bt << ", ct=" << ct << endl;
    }

    cout << ans << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
int main()
{
	string s, t;
	cin >> s >> t;

	vector<int> k;
	bool flag = false;
	for (int i = 0; i + t.size() <= s.size(); i++) {
		bool flag2 = true;
		rep(j, t.size()) {
			if (!(s[i + j] == t[j] || s[i + j] == '?'))  flag2 = false;
		}
		if (flag2) {
			k.push_back(i);
			flag = true;
		}
	}
	if (flag) {
		int v = k[k.size() - 1];
		rep(i, t.size()) {
			s[v + i] = t[i];
		}
		rep(i, s.size()) {
			if (s[i] == '?')  s[i] = 'a';
		}
		cout << s << endl;
		return 0;
	}
	else {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;

int n;
char s[N] , t[N];
int nxt[N] , pre[N] , cnt[N];

int has1(int l , int r) {
    if (l <= r) {
        return cnt[r + 1] - cnt[l];
    } else {
        return cnt[n] - cnt[l] + cnt[r + 1];
    }
}

int main() {
    scanf("%s%s" , s , t);
    n = strlen(s);

    for (int i = 0 ; i < n ; ++ i) {
        cnt[i + 1] = cnt[i] + (t[i] == '1');
    }

    bool find1 = 0;
    for (int i = 0 ; i < n ; ++ i) {
        if (t[i] == '1') {
            find1 = 1;
            break;
        }
    }
    if (!find1) {
        for (int i = 0 ; i < n ; ++ i) {
            if (s[i] == '1') {
                find1 = 1;
                break;
            }
        }
        puts(find1 ? "-1" : "0");
        return 0;
    }
    for (int i = 0 ; i < n ; ++ i) {
        int j = 0;
        while (t[(i + j) % n] == '0') {
            ++ j;
        }
        nxt[i] = j;
    }
    for (int i = 0 ; i < n ; ++ i) {
        int j = 0;
        while (t[(i + n - j) % n] == '0') {
            ++ j;
        }
        pre[i] = j;
    }

    int res = 1 << 30;
    for (int k = 0 ; k < n ; ++ k) {
        //cout << res << endl;
        // b[i] = a[(i + k) % n]

        // Left:
        vector< pair<int , int> > v;
        int cnt = 0;
        for (int i = 0 ; i < n ; ++ i) {
            if (t[i] != s[(i + k) % n]) {
                ++ cnt;
                int l = i , r = (i + k) % n;
                if (!has1(l , r)) {
                    v.push_back({pre[l] , nxt[r]});
                }
            }
        }
        sort(v.begin() , v.end());
        reverse(v.begin() , v.end());
        int m = v.size() , R = 0;
        for (int i = 0 , j = 0 ; i < m ; ++ i) {
            res = min(res , cnt + k + 2 * (v[i].first + R));
            while (j < m && v[i].first == v[j].first) {
                R = max(R , v[j ++].second);
            }
            i = j - 1;
        }
        res = min(res , cnt + k + 2 * R);

        v.clear();
        for (int i = 0 ; i < n ; ++ i) {
            if (t[i] != s[(i + k) % n]) {
                int l = (k + i) % n , r = i;
                if (!has1(l , r)) {
                    v.push_back({pre[l] , nxt[r]});
                }
            }
        }
        sort(v.begin() , v.end());
        reverse(v.begin() , v.end());
        m = v.size() , R = 0;
        for (int i = 0 , j = 0 ; i < m ; ++ i) {
            res = min(res , cnt + n - k + 2 * (v[i].first + R));
            while (j < m && v[i].first == v[j].first) {
                R = max(R , v[j ++].second);
            }
            i = j - 1;
        }
        res = min(res , cnt + n - k + 2 * R);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ctime>
#include <set>
#include <sstream>
#include <bitset>
#define fi first
#define se second
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define MAXN 200009
using namespace std;

int main () {
    int n, m;
    cin>>n>>m;
    ll sum = 0;
    for (int i = 0; i < m; i++) {
        int x;
        cin>>x;
        sum += x;
    }
    if (n - sum < 0) cout<<-1;
    else cout<<n - sum;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int a,b;
    cin >> a >> b;
    if (a%2 == 1 and b%2 == 1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int N = Integer.parseInt(in.readLine());
		System.out.println((N / 3));
	}

	void calc() {
	}

	void showResult() {
	}
}

Measured memory_bytes: 21204
import os
import sys

# from libs.debug import debug

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
C = list(map(int, sys.stdin.buffer.readline().split()))
C.sort(reverse=True)


def div_mod(a, b, mod):
    return a * pow(b, mod - 2, mod) % mod


# (1+x)^k = kC0 * x^0 + kC1 * x^1 + kC2 * x^2 + ... + kCk * x^k
# (1+x)^k * x = kC0 * x^1 + kC1 * x^2 + kC2 * x^3 + ... + kCk * x^(k+1)
# 微分して x=1 を代入すると、上から1番目からk番目になる通り数 * D の総和になる
# kC0 * 1 + kC1 * 2 + kC2 * 3 + ... + kCk * (k+1)
def df(k):
    # (1+x)^x * x を微分した値を返す。
    # https://mathtrain.jp/composite
    # http://w3e.kanazawa-it.ac.jp/math/category/bibun/keisan/diff-gh.html
    # f(x) = 1+x
    # g(x) = x^k
    # h(x) = x
    # g(f(x)) * h(x) = (1+x)^k * x
    # f'(x) = 1
    # g'(x) = kx^(k-1)
    # h'(x) = 1
    # g'(f(x)) = g'(f(x)) * f'(x) = k(1+x)^(k-1)
    # (g(f(x)) * h(x))' = g'(f(x)) * h(x) + g(f(x)) * h'(x)
    #                   = k(1+x)^(k-1) + (1+x)^k
    # (g(f(1)) * h(1))' = k * 2^(k-1) + 2^k
    #                   = k * 2^k / 2 + 2^k
    #                   = (k + 2) / 2 * 2^k
    return div_mod((k + 2) * pow(2, k, MOD), 2, MOD)


ans = 0
for k in range(N):
    # k までの選び方 * 上から何番目か * C[k] * k より後ろの選び方
    ans += df(k) * C[k] * pow(2, N - k - 1, MOD)
    ans %= MOD
print(ans * pow(2, N, MOD) % MOD)


Measured memory_bytes: 23372
import sys
data = sys.stdin.readlines()

def func (list):
	for i in list:
		if len(i)>=2 and i[0]=='0': return 0
	return 1

for s in data:
	for i in range(10):
		tmp = s.replace('X',str(i))
#		print tmp
		tmp = tmp.replace('+','=')
		tmp = tmp[:-1]
		list = tmp.split('=')
#		print (func(list))
		if func(list)==1 :
			if int(list[0])+int(list[1])==int(list[2]) :
				print i
				break
		if i==9 :
			print "NA"

Measured memory_bytes: 6512
#include<iostream>
using namespace std;
#define ll long long
#define Okay_Bye return 0
#define fo(i,n) for(auto i=0;i<n;i++)
#define f1(i,n) for(auto i=1;i<=n;i++)
#define pn printf("\n")
#define Maxn 100005
ll n,a[Maxn],dp[Maxn];
ll fou(ll i){
    if(i==(n-1))return 0;
    if(i>=n) return INT_MAX;
    if(dp[i]!=-1) return dp[i];
    ll left = abs(a[i]-a[i+1])+fou(i+1);
    //cout<<left<<endl;
    ll right = INT_MAX;
    if((i+2)<(n)){
        right = abs(a[i]-a[i+2])+fou(i+2);
    }
    return dp[i]=min(left,right);
}
void solve(){
    //int n,m;
     cin>>n;
    fo(i,n)cin>>a[i];
    //cout<<"ok"<<endl;
    memset(dp,-1, sizeof dp);
    //cout<<"ok"<<endl;
    cout<<fou(0)<<endl;
    //pn;
}

int main()
{
	int t=1;
	//cin>>t;
	while(t--)solve();
	Okay_Bye;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

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


int main() {

	ll N;
	cin >> N;

	vector<ll> A(N + 1), ans(N + 1, 0);

	for (ll i = 2; i <= N; i++) { cin >> A[i]; }

	for (ll i = 2; i <= N; i++) { ans[A[i]]++; }

	repn(i, N) cout << ans[i] << endl;

	system("PAUSE");
}


Measured memory_bytes: 6428