akhauriyash/Code-Regression huggingface dataset:
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
#include<iomanip>
#include <list>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int mod = (int)1e9 + 7;
const int mod1 = (int)1e9 + 9;
const int mod2 = 998244353;
const int mod3 = (int)1e6+3;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
ll max(ll a,ll b){
    return (a<b)? b:a;
}
ll min(ll a,ll b){
    return (a>b)? b:a;
}

vector<int> q;
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);<<" "
    //ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    int i;
    ll a[n];
    rep(i,0,n){
        cin>>a[i];
        if(a[0]>0||(i>0&&a[i]>=a[i-1]+2)){
            cout<<-1;
            return 0;
        }
    }
    ll ans=0;
    rep(i,0,n){
        if(i<n-1&&a[i]!=a[i+1]-1){
            ans+=a[i];
        }
        else if(i==n-1){
            ans+=a[i];
        }
    }
    cout<<ans;
    return 0;
             
    
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

vector<int> G[60];
int a[1000], b[1000];
bool d[60];
void dfs(int v, int parent, int nv, int nto) { 
	d[v] = true;
	for (int to : G[v]) {
		if (to == parent || d[to]) continue;
		if ((to == nto && v == nv) || (to == nv && v == nto)) continue;
		dfs(to, v, nv, nto);
	}
}
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	int ans = 0;
	for (int i = 0; i < M; i++) {
		for (int i = 0; i < N; i++) d[i] = false;
		dfs(0, -1, a[i], b[i]);
		for (int i = 0; i < N; i++) {
			if (!d[i]) {
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
}


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if((x)>(y))(x)=(y)
#define chmax(x,y) if((x)<(y))(x)=(y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, x[200200];
vpii p;
int r[200200];

signed main() {
	cin >> n;
	rep(i,n) cin >> x[i];
	rep(i,n) p.pb({x[i], i});
	sort(all(p));
	rep(i,n/2) r[p[i].se] = p[n/2].fi;
	reps(i,n/2,n) r[p[i].se] = p[n/2-1].fi;
	rep(i,n) cout << r[i] << ln;
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n,w;
	while(cin>>n>>w,n){
		vector<int> a(n);
		REP(i,n)cin >> a[i];
		int histsize = *max_element(a.begin(),a.end()) / w + 1;
		vector<int> graph(histsize);
		REP(i,n)graph[a[i]/w]++;
		int maxgraph = *max_element(graph.begin(),graph.end());
		double ans = 0.01;
		REP(i,histsize)ans += (double)(histsize - i - 1) / (histsize - 1) * graph[i] / maxgraph;
		cout << fixed << setprecision(5) << ans << endl;
	}
  return 0;
}

Measured memory_bytes: 3232
n,m=map(int,input().split())
if m-n>=2018:
  print(0)
else:
  l=[]
  for i in range(n,m+1):
    l.append(i%2019)
  t=10000
  for i in range(len(l)-1):
    for j in range(i+1,len(l)):
      if t>(l[i]*l[j])%2019:
        t=(l[i]*l[j])%2019
  print(t)


Measured memory_bytes: 3060
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 200000;
int N;
int a[MAX_N+1];

int main() {
  cin >> N;
  for (int i = 1; i <= N; ++i) cin >> a[i];
  
  if (N == 1) {
    printf("%d\n", a[1]);
    return 0;
  }

  if (N%2 == 0) {
    for (int i = N; i > 0; i -= 2) {
      printf("%d ", a[i]);
    }
    for (int i = 1; i <= N; i += 2) {
      printf("%d%c", a[i], i == N-1 ? '\n' : ' ');
    }
  } else {
    for (int i = N; i > 0; i -= 2) {
      printf("%d ", a[i]);
    }
    for (int i = 2; i <= N; i += 2) {
      printf("%d%c", a[i], i == N-1 ? '\n' : ' ');
    }
  }

  return 0;
}


Measured memory_bytes: 2944
$%=<>;@_=<>;(pop@_)=~$";map{push@{$`+~-$_*$%},$'+$_%3*$%for/ /..3}@_;@d[@q=$`]=3;map$d[$_]//=((push@q,$_),$d[$q]+1),@{$q=$_}for@q;print$d[$']/3-1

Measured memory_bytes: 198784
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;


int main(){
    int n; cin >> n;
    long long k; cin >> k;
    int a;
    long long b;
    vector<pair<int, int>> nums(n);
    for (int i=0;i<n;i++){
        cin >> a >> b;
        nums[i] = {a, b};
    }
    sort(nums.begin(), nums.end());

    for (auto item: nums){
        k -= item.second;
        if (k <= 0){
            cout << item.first << endl;
            break;
        }
    }
    return 0;

}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		
		char[] a = sc.next().toCharArray();
		char[] b = sc.next().toCharArray();
		
		if (a.length < b.length) {
			System.out.println("LESS");
		} else if (a.length > b.length) {
			System.out.println("GREATER");
		} else {
			int n = a.length;
			for (int i = 0; i < n; i++) {
				if (a[i] < b[i]) {
					System.out.println("LESS");
					return;
				} else if (a[i] > b[i]) {
					System.out.println("GREATER");
					return;
				}
			}
			System.out.println("EQUAL");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<cat> A(N+2, 0);
	for(int i = 0; i < N; i++) cin >> A[i+1];
	vector<cat> dist(N+2, 0), dist_inv(N+2, 0);
	for(int i = 0; i < N+1; i++) dist[i+1] = dist[i] + abs(A[i]-A[i+1]);
	for(int i = N; i >= 0; i--) dist_inv[i] = dist_inv[i+1] + abs(A[i]-A[i+1]);
	for(int i = 1; i <= N; i++) cout << dist[i-1]+dist_inv[i+1]+abs(A[i-1]-A[i+1]) << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 3584
Scanf.scanf "%d %d" (fun n k ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a - 1)) in
    let tel = Array.make n (-1) in
    let ord = Array.make n (-1) in
    tel.(0) <- 0;
    ord.(0) <- 0;

    let rec loop step cur =
        let step = step + 1 in
        let cur = a.(cur) in
        if step = k then cur + 1 else
        if tel.(cur) = -1 then (
            tel.(cur) <- step;
            ord.(step) <- cur;
            loop step cur
        ) else (
            let len = step - tel.(cur) in
            let rest = (k - step) mod len in
            ord.(tel.(cur) + rest) + 1
        )
    in
    loop 0 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 10760
def scoring(d, t, k=10):
    arr = [l for l in last]
    arr[t] = d
    penalty = sum((d - l) * c for l, c in zip(arr, C))
    score = S[d][t] - penalty
    score -= (min(D, d + k) - d - 1) * penalty
    return score

D = int(input())
C = list(map(int, input().split()))
S = []
for _ in range(D):
    s = list(map(int, input().split()))
    S.append(s)
last = [-1] * 26
ans = []
for i in range(D):
    res = -10 ** 6
    idx = -1
    for j in range(26):
        tmp = scoring(i, j)
        if tmp > res:
            res = tmp
            idx = j
    last[idx] = i
    ans.append(idx+1)
print(*ans, sep='\n')

Measured memory_bytes: 9496
#include <stdio.h>

#define N 10000

int S[N],T[N];

int n,q;

int search(int);

int main(){

  int i,j,c=0;

  scanf("%d",&n);

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

  for(i=0; i<q; i++){
   
    if(search(T[i]) == 1) c++;
  }

  printf("%d\n",c);


  return 0;
}

int search(int key){

  int i;
  for(i=0; i<n; i++){
    if(S[i] == key) return 1;
  }

  return 0;
}

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

int main()
{
    int n, x, y;
    cin >> n >> x >> y;

    vector<vector<int>> G(n);
    for (int i = 1; i <= n - 1; i++)
    {
        G[i - 1].push_back(i);
        G[i].push_back(i - 1);
    }
    x--;y--;
    G[x].push_back(y);
    G[y].push_back(x);

    vector<int> ans(n, 0);
/*
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < (int)G[i].size(); j++)cout << G[i][j] << " ";
        cout << endl;
    }
*/
    for (int i = 0; i < n; i++)
    {
        vector<int> dist(n, -1);
        queue<int> que;

        dist[i] = 0;
        que.push(i);

        while (!que.empty())
        {
            int v = que.front();
            que.pop();

            for (int nv : G[v])
            {
                if(dist[nv] != -1)continue;
                dist[nv] = dist[v] + 1;
                que.push(nv);
            }
        }
        
        for (int j = i; j < n; j++)
        {
            ans[dist[j]]++;
        }
    }
    
    for (int i = 1; i < n; i++)
    {
        cout << ans[i] << endl;
    }
    
}

Measured memory_bytes: 3752
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

#define ll long long

int main(void){

    string s;
    cin>>s;
    int a=s.size(),z=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A')a=min(a,i);
        else if(s[i]=='Z')z=max(z,i);
    }
    cout<<z-a+1<<endl;

    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

ll ans[202020];

int main(){

    ll N, x;
    cin >> N >> x;
    if(x == 1 || x == 2 * N - 1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    ans[N - 1] = x - 1;
    ans[N] = x;
    ans[N + 1] = x + 1;
    ll nxt = 1;
    rep1(i, 2 * N - 1){
        if(ans[i])continue;
        while(abs(x - nxt) <= 1)nxt++;
        ans[i] = nxt;
        nxt++;
    }
    rep1(i, 2 * N - 1)cout << ans[i] << endl;
    
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG

int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}

int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}

void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}

void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}

void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}

void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}



int main() {
  string S;
  string T;
  cin >> S >> T;
  int X=S.size();
  int ans=0;
  for(int i=0;i<X;i++){
    if(S.at(i)!=T.at(i)){
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3844
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <cstring>

using namespace std;
#define int long long
const int mod = 1000000007;


signed main(){
	string s;
	cin >> s;
	for (int i = 2; i < s.length(); i++) {
		if (i == 2) {
			if (s[i - 2] == s[i - 1]) {
				cout << i - 1 << " " << i + 1 << endl;
				return 0;
			}
		}
		if (s[i - 2] == s[i]) {
			cout << i - 1 << " " << i + 1 << endl;
			return 0;
		}
		else if (s[i - 1] == s[i]) {
			cout << i-1 << " " << i + 1 << endl;
			return 0;
		}
	}
	if (s.length() == 2) {
		if (s[0] == s[1]) {
			cout << "1 2" << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;

}


Measured memory_bytes: 512
n, a, b = map(int, input().split())
p = list(map(int, input().split()))

INF = 10**13
dp = [[INF for _ in range(n+1)] for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
	for j in range(n+1):
		if j < p[i]:
			dp[i+1][p[i]] = min(dp[i+1][p[i]], dp[i][j])
			dp[i+1][j] = min(dp[i+1][j], dp[i][j] + a)
		else:
			dp[i+1][j] = min(dp[i+1][j], dp[i][j] + b)

print(min(dp[n]))

Measured memory_bytes: 246408
function main(input) {
    var arr = []
    var input = input.split("\n")
    input = input[1].split(" ")
  
    var v = 0
    for (var k in input) {
      v += Number(input[k])
    }
  	v -= input.length
  	console.log(v)
  }
  main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

N = int(input())
A = list(map(int, input().split()))

tmp = 0
zero = False
B = []
for a in A:
    if a < 0:
        tmp += 1
    elif a == 0:
        zero = True
    B.append(abs(a))

if tmp % 2 == 0 or zero:
    ans = sum(B)
else:
    ans = sum(B) - 2*min(B)

print(ans)

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

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n = int(sys.stdin.readline())
	if n % 1000 == 0:
		print(0)
	else:
		print((n//1000+1)*1000-n)
	


main()

Measured memory_bytes: 68412
#include "bits/stdc++.h"
using namespace std;
int main(){
  int n,a,b,XYmin;
  cin >> n >> a >> b;
  if(n > a+b){
    XYmin = 0;
  }else{
    XYmin = (a+b)-n;
  }
  cout << min(a,b) << " " << XYmin;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 200005
using namespace std;
typedef long long ll;
inline int read(){
	int sum = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') t = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ sum = sum * 10 + ch - '0'; ch = getchar(); }
	return sum * t;
}

int n, q, A, B;
ll ans, tag;

struct segment{
	ll pre[N<<2], suf[N<<2];
	#define ls ri << 1
	#define rs ri << 1 | 1
	#define mid (l + r >> 1)
	#define to_l ls, l, mid
	#define to_r rs, mid + 1, r
	void build(int ri, int l, int r){
		if(l == r){
			if(l == A) pre[ri] = -l, suf[ri] = l;
			else pre[ri] = suf[ri] = 1LL << 60;
			return ;
		}
		build(to_l); build(to_r);
		pre[ri] = min(pre[ls], pre[rs]);
		suf[ri] = min(suf[ls], suf[rs]);
	}
	
	void modify(int ri, int l, int r, int pos, ll w){
		if(l == r){
			pre[ri] = w - l; suf[ri] = w + l;
			return ;
		}
		if(pos <= mid) modify(to_l, pos, w);
		else modify(to_r, pos, w);
		pre[ri] = min(pre[ls], pre[rs]);
		suf[ri] = min(suf[ls], suf[rs]);
	}
	
	ll askl(int ri, int l, int r, int pos){
		if(l == r) return pre[ri];
		if(pos <= mid) return askl(to_l, pos);
		else return min(pre[ls], askl(to_r, pos));
	}
	
	ll askr(int ri, int l, int r, int pos){
		if(l == r) return suf[ri];
		if(pos <= mid) return min(suf[rs], askr(to_l, pos));
		else return askr(to_r, pos);
	}
	
	void solve(int ri, int l, int r){
		if(l == r){
			ans = min(ans, pre[ri] + l);
			return ;
		}
		solve(to_l); solve(to_r);
	}
}S;

int main(){
	n = read(); q = read();
	A = read(), B = read();
	S.build(1, 1, n);
	for(; q ; q--){
		int x = read();
		ll res = min(S.askl(1, 1, n, x) + x, S.askr(1, 1, n, x) - x);
		tag += abs(x - B);
		S.modify(1, 1, n, B, res - abs(x - B));
		B = x;
	}
	ans = 1LL << 60;
	S.solve(1, 1, n);
	printf("%lld\n", ans + tag);
}


Measured memory_bytes: 12416
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 3*1e5+5;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    ///freopen("a.in","r",stdin);
    ///freopen("a.out","w",stdout);
    int n;
    cin>>n;
    vi v(n),d(n);
    rep(i,n)cin>>v[i],d[i]=v[i]-(i+1);
    sort(all(d));
    int b=d[n/2];
    int ans=0;
    rep(i,n){
        ans+=abs(d[i]-b);
    }
    cout<<ans<<enl;

    return 0;
}


Measured memory_bytes: 6356
#include<bits/stdc++.h>
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
using namespace std;
const ll mod=1e9+7;
const int N=1e5+4;
int main()
{
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double ans=w*h;
    ans/=2;
    cout<<ans<<" ";
    if(x==w/2&&y==h/2)
    cout<<1;
    else
    cout<<0;
    return 0;
}

Measured memory_bytes: 256
S = input()

S1 = S[:2]
S2 = S[2:]

def is_MM(s):
    if 1 <= int(s) <= 12:
        return True
    else:
        return False
    
if is_MM(S1):
    if is_MM(S2):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if is_MM(S2):
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main() {
    ll n;
    string s;
    cin>>n;
    cin>>s;
 
     if(n>=s.length())
     cout<<s;
     else
    {
        for(ll i=0;i<n;i++)
        {
        cout<<s[i];
        }
        cout<<"...";
    }
    
}

Measured memory_bytes: 3620
package main

import "fmt"

// R - win by rock point
var R int

// S - win by sissors point
var S int

// P - win by paper point
var P int

func main() {
	var N, K int
	fmt.Scan(&N, &K, &R, &S, &P)
	var T string
	fmt.Scan(&T)
	type s struct {
		data []byte
	}
	ss := make([]s, K)
	for i := 0; i < N; i++ {
		ss[i%K].data = append(ss[i%K].data, T[i])
	}
	ans := 0
	for i := 0; i < K; i++ {
		// fmt.Printf("i %d -> substring %s\n", i, string(ss[i].data))
		L := len(ss[i].data)
		dp := make([][3]int, L+2) // j回ジャンケンをした結果の最大得点
		// 初期値は0
		// あり得る遷移のパターン
		// dp[j][0] => dp[j+1][1], dp[j+1][2]
		// dp[j][1] => dp[j+1][0], dp[j+1][2]
		// dp[j][2] => dp[j+1][0], dp[j+1][1]
		for j := 0; j < L; j++ {
			// 直前と同じ手は出せない制約下で得点を最大化する
			dp[j+1][0] = max(dp[j][1]+winp(ss[i].data[j], 'r'), dp[j][2]+winp(ss[i].data[j], 'r'))
			dp[j+1][1] = max(dp[j][0]+winp(ss[i].data[j], 's'), dp[j][2]+winp(ss[i].data[j], 's'))
			dp[j+1][2] = max(dp[j][0]+winp(ss[i].data[j], 'p'), dp[j][1]+winp(ss[i].data[j], 'p'))
		}
		sub := max(dp[L][0], max(dp[L][1], dp[L][2]))
		// fmt.Printf("i %d, sub %d, dp %v\n", i, sub, dp)
		ans += sub
	}
	fmt.Println(ans)
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func winp(c, p byte) (r int) {
	if c == p {
		r = 0
	} else if c == 'r' && p == 'p' {
		r = P
	} else if c == 's' && p == 'r' {
		r = R
	} else if c == 'p' && p == 's' {
		r = S
	} else {
		r = 0
	}
	return r
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;
typedef pair<int,int> P;

struct Edge {
    int from, to, cap, rev;
    Edge(int f, int t, int c, int r) : from(f), to(t), cap(c), rev(r) {} // 初期化
};

struct Graph {
    vector<vector<Edge>> G;
    Graph(int n = 0) : G(n) {} // 初期化

    vector<Edge>& operator[](int i) { return G[i]; }
    int size() { return G.size(); }
    void add_edge(int from, int to, int cap) {
        G[from].push_back(Edge(from, to, cap, (int)G[to].size()));
        G[to].push_back(Edge(to, from, 0, (int)G[from].size() - 1));
    } // 有向辺を加える
};

struct Dinic {
    const int INF = 1e9;
    vector<int> level, iter; 
    Dinic(){}; // 初期化

    void bfs(Graph &G, int s){
        level.assign(G.size(), -1);
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while(!que.empty()){
            int v = que.front(); que.pop();
            for(int i=0; i<G[v].size(); i++){
                Edge &e = G[v][i];
                if(e.cap > 0 && level[e.to] < 0){
                    level[e.to] = level[v]+1;
                    que.push(e.to);
                }
            }
        }
    }

    int dfs(Graph &G,int s, int g, int f){
        if(s == g) return f;
        for(int &i = iter[s]; i < G[s].size(); i++){
            Edge &e = G[s][i];
            if(e.cap > 0 && level[s] < level[e.to]){
                int d = dfs(G, e.to, g, min(e.cap, f));
                if(d > 0){
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int max_flow(Graph &G, int s, int g){
        int flow = 0;
        while(true){
            bfs(G,s);
            if(level[g] < 0) return flow;
            iter.assign(G.size(), 0);
            int f;
            while((f = dfs(G, s, g, INF)) > 0) flow += f;
        }
    }
};

int main(){
    int n; cin >> n;
    int a[n], b[n], c[n], d[n];
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,n) cin >> c[i] >> d[i];
    Graph data(2*n+2);
    rep(i,n) rep(j,n) if(a[i] < c[j] && b[i] < d[j]) data.add_edge(i, j+n,1);
    rep(i,n) data.add_edge(2*n, i, 1);
    rep(i,n) data.add_edge(i+n, 2*n+1, 1);
    Dinic ans;
    cout << ans.max_flow(data, 2*n, 2*n+1) << endl;
}

Measured memory_bytes: 3752
n = list(map(int, input()))

before = n[0]
count = 1
for i in n[1:]:
    if before == i:
        count += 1
        if count==3:
            break
    else:
        before = i
        count = 1
        
if count >=3:
    print('Yes')
else:
    print('No')

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

int main(){
	string s,t; cin>>s>>t;
	int hit = 0;
	if(s[0]==t[0])++hit;
	if(s[1]==t[1])++hit;
	if(s[2]==t[2])++hit;
	cout<< hit <<endl;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  int a,b;
  cin>>a>>b;
  if (a>=10 || b>=10){
    cout << "-1" << endl;
    return 0;
  } else cout << a*b << endl;
}


Measured memory_bytes: 3164
n=int(input())
ii,jj=[0]*n,[0]*n
b=0
for i in range(n):
  s=input()
  for j in range(n):
    k=1if"#"==s[j] else 0
    ii[i]+=k
    jj[j]+=k
    b+=k
if b==0:print(-1);exit()
c=n-jj.count(n)
mi=10000
for i in range(n):
  x=n-ii[i]
  if jj[i]==0:x+=1
  mi=min(x,mi)
print(mi+c)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[10010];string s;ll l;double d;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	double nextDouble(){scanf("%lf", &d);return d;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

int main(){
	int n = in.nextInt(), l = in.nextInt();
	vector<string> s(n);
	rep(i, n) s[i] = in.next();
	sort(all(s));
	rep(i, n) cout<<s[i];
	cout<<endl;
}


Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

h,n=LI()
a=[]
ab=[]
for i in range(n):
    x,y=LI()
    ab.append((-x,y))
ab.sort()
a=[-i for i,j in ab]
b=[j for i,j in ab]
dp=[[0]+[inf]*(h) for i in range(n+1)]    
dp[0][0]=0

for i in range(n):
    for j in range(h+1):
        dp[i+1][min(h,j+a[i])]=min(dp[i+1][j]+b[i],dp[i+1][min(h,j+a[i])],dp[i][min(h,j+a[i])])

ans=dp[n][h]

print(ans)


Measured memory_bytes: 367108
#include<bits/stdc++.h>
// #include"testlib.h"

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e6 + 10;
// const int mod = (int)1e9 + 7;


vector<int> vis, a, b;
map<pair<int, int>, int> in;

void dfs(int x, const pair<int, int> &px){

    if(vis[x]) return;

    vis[x] = true;
    int pv = in[{a[x] - px.X, b[x] - px.Y}];
    int nx = in[{a[x] + px.X, b[x] + px.Y}];

    if(pv != 0) dfs(pv - 1, px);
    if(nx != 0) dfs(nx - 1, px);
}


int main(int argc, char* argv[]){

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

    int n;
    cin >> n;
    
    vis.resize(n, 0);
    a.resize(n, 0);
    b.resize(n, 0);

    for(int i = 0; i < n; ++i){
        cin >> a[i] >> b[i];
        in[{a[i], b[i]}] = i + 1;
    }

    map<pair<int, int>, int> mp;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            if(i == j) continue;
            int p = a[j] - a[i];
            int q = b[j] - b[i];
            mp[{p, q}]++;
        }
    }

    int mx = 0;
    pair<int, int> pa;
    for(auto &ppc : mp){
        int c = ppc.Y;
        auto pp = ppc.X;
        if(c > mx){
            mx = c;
            pa = pp;
        }
    }

    // cout << pa.X << " " << pa.Y << endl;

    int res = 0;
    for(int i = 0; i < n; ++i){
        if(!vis[i]){
            res++;
            dfs(i, pa);
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>


int final_board[8][8] = {{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},
		{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0}};

void deletePossibility(int tmp_board[8][8],int row,int column){
	tmp_board[row][column] = 1;
	for(int i = 0; i < 8; i++){
		if(i != column){
			tmp_board[row][i] = -1;
		}
	}
	for(int i = 0; i < 8; i++){
		if(i != row){
			tmp_board[i][column] = -1;
		}
	}

	for(int r = row-1,c = column+1;r >= 0 && c <= 7; r--,c++){
		tmp_board[r][c] = -1;
	}
	for(int r = row+1,c = column+1;r <= 7 && c <= 7; r++,c++){
		tmp_board[r][c] = -1;
	}
	for(int r = row-1,c = column-1;r >= 0 && c >= 0; r--,c--){
		tmp_board[r][c] = -1;
	}
	for(int r = row+1,c = column-1;r <= 7 && c >= 0; r++,c--){
		tmp_board[r][c] = -1;
	}
}



void func(int tmp_board[8][8],int num_of_putQ){
	if(num_of_putQ == 8){
		for(int i = 0; i < 8; i++){
			for(int k = 0; k < 8; k++){
				final_board[i][k] = tmp_board[i][k];
			}
		}
	}else{

		int row,column,count = 0;
		for(row = 0; row < 8; row++){
			for(column = 0; column < 8; column++){
				if(tmp_board[row][column] == 0){
					count++;
				}
			}
			if(count > 0) break;
		}
		if(row == 8 && column == 8){
			//Do nothing
		}else{
			int tri_board[count][8][8];
			int index = 0;

			for(int a = 0; a < count; a++){
				for(int b = 0; b < 8; b++){
					for(int c = 0; c < 8; c++){
						tri_board[a][b][c] = tmp_board[b][c];
					}
				}
			}

			for(int i = 0; i < 8; i++){
				if(tmp_board[row][i] == 0){
					deletePossibility(tri_board[index],row,i);
					func(tri_board[index++],num_of_putQ+1);
				}
			}
		}

	}
}




int main(){

	int k,row,colum;
	int tmp_board[8][8];

	for(int i = 0; i < 8; i++){
		for(int k = 0; k < 8; k++){
			tmp_board[i][k] = 0;
		}
	}

	scanf("%d",&k);

	for(int i = 0; i < k; i++){
		scanf("%d %d",&row,&colum);
		deletePossibility(tmp_board,row,colum);
	}

	func(tmp_board,k);

	for(int i = 0; i < 8; i++){
		for(int p = 0; p < 8; p++){
			if(final_board[i][p] == 1){
				printf("Q");
			}else{
				printf(".");
			}
		}
		printf("\n");
	}

    return 0;
}



Measured memory_bytes: 2692
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1;  while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  
    int n;
    cin>>n;
    int a[n];
    forr(i,n){
        cin>>a[i];
    }   
    int ans  =0 ;
    forr(i,n){
        ans +=(i%2==0 and a[i]%2==1);
    }
    cout<<ans<<"\n";
return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio

  ll n;
  cin >> n;
  ll m = n / 2 + n % 2;
  ld f = (1.0 * m) / n;
  decimal_digits;
  cout << f << '\n';

  ktj();
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int a,b,c;
    cin >> a >> b >> c;
    if(b/a >= c){
        cout << c << endl;
    }else{
        cout << b/a << endl;
    }
    



    return 0;
}

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

int main() {
  
  int a1,a2,b1,b2 ;
  
 scanf( "%d%d%d%d", &a1,&a2,&b1,&b2 );
  
  if ( (a1+a2) > (b1+b2) ) 
  	puts("Left");
  else if ((a1+a2) == (b1+b2) ) 
    puts("Balanced");
  else
    puts("Right");

 
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 0 || b % 2 == 0) {
		cout << "Even" << endl;
	} else { 
		cout << "Odd" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

struct edge{
    ll to;
    ll cost;
};

int main(void){
    int n; cin >> n;
    int m; cin >> m;
    int p; cin >> p;
    vector <vector <edge>> edges(n+1, vector<edge>());
    REP(i, m){
        int a; cin >> a;
        int b; cin >> b;
        int c; cin >> c;
        edges[a].push_back({b, c-p});
    }
    vector <ll> nodes(n+1, -1e15);
    nodes[1] = 0;
    int i = 1;
    ll score = 0;
    vector <ll> nodes_when_n;
    while (true){
        REP(i, n+1){
            for(auto e: edges[i]){
                nodes[e.to] = max(nodes[i] + e.cost, nodes[e.to]);
            }
        }
        if(i == n) {
            nodes_when_n = nodes;
        }
        if(i > n*2){
            break;
        }
        i++;
    }
    if (nodes[n] != nodes_when_n[n]){
        cout << -1 << endl;
        return 0;
    }
    cout << max(ll(0), nodes[n]) << endl;
    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

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

const int inf=100000000;



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

    int a;
    cin>>a;
    int b;
    cin>>b;
    int ans=0;
    if(a>5&&a<13) ans=b/2;
    if(a>12) ans=b;

    cout<<ans<<endl;



    return 0;

}

Measured memory_bytes: 256
//Sha3ban_El-Bay
#include<bits/stdc++.h>
using namespace std ;
//======================================================
#define El_Bay ios_base::sync_with_stdio(false);cin.tie(NULL);
#define forn(i,n)  for (int i = 0; i < (int)(n); ++i)
#define for1(i,n)  for (int i = 1; i <=(int)(n); ++i)
#define all(v)     (v).begin(),(v).end()
#define ull        unsigned long long
#define PI         3.14159265359
#define ll         long long
#define sz(v)	   v.size()
#define pb         push_back
#define pp         pop_back
#define S          second
#define bgn        begin
#define F          first
#define N          1000000+5
#define	MOD        1e9+7
#define inf        1e18
//======================================================
int dx[] = { 0,  0, 1, -1 ,  1,  -1,  1,  -1 };
int dy[] = { 1, -1, 0,  0 , -1,   1,  1,  -1 };
//======================================================
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ull a, ull b, ull ret = 1LL) {
	while (b--) ret = (ret * a);
	return ret;}
//======================================================
ll n,ans,w;
ll dp[110][N],a[110],b[110];
ll solve( ll i, ll r )
{
	if(r<0) return INT_MIN;
	if(i==n || r==0 ) return 0;
	if(dp[i][r]!=-1) return dp[i][r];

	dp[i][r] = max( solve(i+1,r) , solve(i+1,r-a[i])+b[i] );

	return dp[i][r];
}
int main()
{
	El_Bay
	cin >> n >> w ;
	for(int i=0 ; i<n ; i++)
		cin >> a[i] >> b[i];

	memset(dp,-1,sizeof(dp));

	cout << solve(0,w);
	return 0;
}




Measured memory_bytes: 863024