akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 100000007;
const int inf = 100000005;
const int N = 200005, M = N;
int i,j,n,m;

ll cnt , idx;
vi temp;


void solve() {
  ll x;
  cin>>x;

  priority_queue<ll>pq;
  pq.push(x);

  ll cnt = 1;
  ll j = 1;

  while(!pq.empty()) {
    ll k = pq.top();
    pq.pop();
    if(k == 1) {
        break;
    }
    cnt+=(1LL<<j);
    j++;
    pq.push(k/2);
  }
  cout<<cnt<<"\n";
}

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

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

    return 0;
}




Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define MAX 100000
#define MOD 1000000007
using namespace std;
int v[MAX],a[MAX];
bool check(int n)
{
	for(int i=0;i<n;++i)
		if(a[i]^v[i])
			return false;
	return true;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	for(int i=0,x;i<n;++i)
	{
		cin>>x;
		a[x]++;
		++v[abs(n-1-(i<<1))];
	}
	long long ans = 0;
	if(check(n))
	{
		n >>= 1;
		ans = 1;
		for(int i=1;i<=n;++i)
			ans <<=1, ans %= MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4320
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int len = s.length();
        int stt = len % 2 == 0 ? 2 : 1;
        for(int i = stt; i < len; i += 2){
            String s1 = s.substring(0,len-i);
            String s2 = s1.substring(0,s1.length()/2);
            String s3 = s1.substring(s1.length()/2,s1.length());
            if(s2.equals(s3)){
                System.out.println(s1.length());
                break;
            }
        }
    }
}

Measured memory_bytes: 23764
package main

import "fmt"


func main(){
	var n,min,count int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := 0 ; i < n ; i++ {
		fmt.Scan(&p[i])
		if i == 0 {
			min = p[i]
			count++
		} else if min >= p[i] {
			count++
			min = p[i]
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	ll N;
	cin >> N;
	vector<ll> A(N);
	map<ll, ll> mp;
	for(ll i = 0; i < N; i++){
		cin >> A[i];
		mp[A[i]]++;
	}
	ll ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		ans += itr->second * (itr->second-1) / 2;
	}
	for(ll i = 0; i < N; i++){
		cout << ans - (mp[A[i]] * (mp[A[i]]-1) / 2) + ((mp[A[i]]-1) * (mp[A[i]]-2) / 2) << endl;
	}

    return 0;
}


Measured memory_bytes: 11008
def get_weight( n, ans )
	fundou = [ 512, 256, 128 , 64, 32, 16, 8, 4, 2,1 ]
	fundou.each{ |f|
		if n >= f
			n -= f
			ans << f 
		end
	}
	ans.reverse!
end

answers = Array.new
while line = $stdin.gets
	ans = Array.new
	weight = line.chomp.to_i
	get_weight( weight, ans )
	answers << ans.dup
end
answers.each{ |a|
	a.each_with_index{ |e,i| 
		if i > 0
			print " "
		end
		print e
	}
	puts
}


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



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

    double r; cin >> r;
    cout << fixed << setprecision(12) << 2.0*r*M_PI << endl;
}

Measured memory_bytes: 3800
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N, A := getInt(), getInt()

	out(N*N - A)
}


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

#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define pp popo_back
#define nl printf("\n");
#define sf scanf
#define pf printf
#define rep(i,n) for(ll i=0;i<n;i++)
#define vint vector<int> 
#define  tc int t;scanf("%d",&t);while(t--) 
int main()
{
	int a,b;
	cin>>a>>b;
	int c=a+b;

cout<<c%24;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>   
 
int main(void)     
 
{     
 
int a,b;     
 
scanf("%d",&a);     
 
scanf("%d",&b);     
 
printf("%d %d\n",a*b,2*a+2*b);     
 
return 0;     
 
}
 

 

Measured memory_bytes: 2656
#include "bits/stdc++.h"

using namespace std;
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; }

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};

int d;
ll g;
vector<ll> p(15) , c(15);

int main(void){
	cin>>d>>g;
	for(int i=0;i<d;i++) cin>>p[i]>>c[i];

	ll res = 1<<29;
	for(int bit = 0;bit < (1<<d);bit++) {
		ll sum = 0;
		ll num = 0;
		for(int i=0;i<d;i++) {
			if(bit & (1<<i)) {
				sum += c[i] + p[i] * 100 * (i+1);
				num += p[i];
			}
		}
		if(g <= sum) res = min(res, num);
		else {
			for(int i = d - 1;i >= 0;i--) {
				if(bit & (1 << i)) continue;
				for(int j=0;j<p[i];j++) {
					if(g <= sum) break;
					sum += 100 * (i+1);
					num++;
				}
			}
			res = min(res, num);
		}
	}

	cout<< res <<endl;		
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.lang.Math;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int len = Integer.parseInt(br.readLine());
    String[] strs = br.readLine().split(" ");
    int[] numbers = new int[len];
    for (int i = 0; i < len; i++) {
      numbers[i] = Integer.parseInt(strs[i]);
    }
    Arrays.sort(numbers);
    int left = numbers[0], right = numbers[len-1];
    int sum = 0, min = 0;
    for (int i = left; i <= right; i++) {
      for (int j = 0; j < len; j++) {
        sum += Math.pow(numbers[j] - i, 2);
      }
      if (min == 0) {
        min = sum;
      } else {
        min = Math.min(min, sum);
      }
      sum = 0;
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

int main()
{
	INT n;
	cin >> n;
	vector<INT> h(n + 2);
	h[0] = 0;
	h[n + 1] = 1000000001;
	for (size_t i = 0; i < n; i++)
	{
		cin >> h[i + 1];
	}

	for (size_t i = n; i >= 1; i--)
	{
		if (h[i + 1] < h[i])
		{
			h[i]--;
		}
		if (h[i + 1] < h[i])
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,x;
    
    cin>>n>>x;
    
    int L[n];
    int sum=0;
    int ans=0;
    for(int i=0; i<n; i++){
        cin>>L[i];
        //cout << sum << endl;
        sum=sum+L[i];
        if(sum<=x){
            ans++;
        }
    }
    cout << ans+1 << endl;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=300000+19;
const ll oo=1ll<<60;

struct Point{
	ll x,y;
	ll At(ll w){
		return x*w+y;
	}
} stk[N];
typedef Point Vector;

Vector operator - (Point A,Point B) {return (Vector){A.x-B.x,A.y-B.y};}
db cross(Vector A,Vector B){
	return 1.0*A.x*B.y-1.0*A.y*B.x;
}

ll sl[N],sr[N],T[N],f[N],g[N],res[N],val[N];
int n,x,v,top,Qc;

struct QType{
	int v,id;
};vector<QType> V[N];

void Query(int i){
	while (top>=2){
		Point B=stk[top];
		Point A=stk[top-1];
		if (B.At(i)<=A.At(i)) top--;else break;
	}
}
void Insert(Point C){
	while (top>=2){
		Point B=stk[top];
		Point A=stk[top-1];
		if (cross(B-A,C-A)<=0) top--;else break;
	}
	stk[++top]=C;
}
void Work(int l,int r){
	if (l==r) return;
	int mid=((l+r)>>1);
	
	//[l,mid]->[mid+1,r]
	top=0;
	stk[++top]=(Point){0,0};
	For(i,l,mid+1){
		Insert((Point){-i,f[i]+(1ll*i*i-i)/2+sl[i]});
	}
	For(i,mid+1,r+1){
		Query(i);
		val[i]=stk[top].At(i)+(1ll*i*i+i)/2-sl[i];
	}
	ll mx=-oo;
	for (int i=r;i>mid;i--){
		mx=max(mx,val[i]+g[n-i]);
		for (QType Q:V[i]){
			res[Q.id]=max(res[Q.id],mx+T[i]-Q.v);
		}
	}
	
	//[l,mid]<-[mid+1,r]
	top=0;
	stk[++top]=(Point){0,0};
	for (int j=r,i;j>mid;j--){
		i=n-j+1;
		Insert((Point){-i,g[i]+(1ll*i*i-i)/2+sr[i]});
	}
	for (int j=mid,i;j>=l;j--){
		i=n-j+1;
		Query(i);
		val[j]=stk[top].At(i)+(1ll*i*i+i)/2-sr[i];
	}
	mx=-oo;
	for (int j=l;j<=mid;j++){
		mx=max(mx,val[j]+f[j-1]);
		for (QType Q:V[j]){
			res[Q.id]=max(res[Q.id],mx+T[j]-Q.v);
		}
	}

	Work(l,mid);
	Work(mid+1,r);
}
void calc(ll *res,ll *sum){
	top=0;
	stk[++top]=(Point){0,0};
	For(i,1,n+1){
		Query(i);
		res[i]=max(res[i-1],stk[top].At(i)+(1ll*i*i+i)/2-sum[i]);
		Insert((Point){-i,res[i]+(1ll*i*i-i)/2+sum[i]});
	}
}

int main(){
	n=IN();
	For(i,1,n+1) T[i]=IN();
	For(i,1,n+1){
		sl[i]=sl[i-1]+T[i];
		sr[i]=sr[i-1]+T[n-i+1];
	}
	calc(f,sl);
	calc(g,sr);
	Qc=IN();
	For(i,1,Qc+1){
		x=IN(),v=IN();
		V[x].pb((QType){v,i});
		res[i]=f[x-1]+g[n-x];
	}
	
	Work(1,n);
	
	For(i,1,Qc+1) printf("%lld\n",res[i]);
}

Measured memory_bytes: 36480
#include <bits/stdc++.h>
using namespace std;
int main(){
        long double l; cin >> l;
        l = (long double)(l / 3);
        l = (long double)l * (long double)l * (long double)l;
        cout << fixed << setprecision(20);
        cout << l << endl;
    return 0;
}


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

int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h+2, vector<char>(w+2,'#'));
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) cin >> s[i][j];
  }
  vector<vector<int>> v(h+2, vector<int>(w+2,0));
  vector<vector<int>> pa(h+2, vector<int>(w+2,0));
  for(int i = 1; i <= h; i++) {
    int p = 1;
    for(int j = 1; j <= w+1; j++) {
      if(s[i][j] == '.' && s[i][j-1] == '#') p = j;
      else if(s[i][j-1] == '.' && s[i][j] == '#') {
        for(int k = p; k < j; k++) pa[i][k] = j-p;
      }
    }
  }
  for(int i = 1; i <= w; i++) {
    int p = 1;
    for(int j = 1; j <= h+1; j++) {
      if(s[j][i] == '.' && s[j-1][i] == '#') p = j;
      else if(s[j-1][i] == '.' && s[j][i] == '#') {
        for(int k = p; k < j; k++) v[k][i] = j-p;
      }
    }
  }
  int ans = 0;
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) ans = max(ans,v[i][j]+pa[i][j]);
  }
  cout << ans-1 << endl;
  return 0;
}

Measured memory_bytes: 35712
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#include <random>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

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

random_device gen;
mt19937 rnd(gen());

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

deque<int> now;
vector<int> a[nmax];
bool used[nmax];
int n, m;

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
	cin >> n >> m;
	int x, y;
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &x, &y);
		x--, y--;
		a[x].pb(y);
		a[y].pb(x);
	}
	now.pb(x);
	now.pb(y);
	used[x] = used[y] = true;
	while (true) {
		bool f = false;
		for (int u : a[now[0]]) {
			if (!used[u]) {
				f = true;
				used[u] = true;
				now.push_front(u);
				break;
			}
		}
		for (int u : a[now.back()]) {
			if (!used[u]) {
				f = true;
				used[u] = true;
				now.push_back(u);
				break;
			}
		}
		if (!f) break;
	}
	printf("%d\n", (int)now.size());
	for (int u : now) {
		printf("%d ", u + 1);
	}
	return 0;
}



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

int main(){
  ios::sync_with_stdio(false);
  int n, d;
  int ans, min = 100;
  cin >> n >> d;

  for(int i=1; i<=20; i++){
    if(i*(2*d+1) >= n){
      if(i < min)
        min = i;
    }
  }

  ans = ans;
  cout << min;
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

const int MOD = 1e9+7;

void Main(){
    int s; cin >> s;
    vi dp(s+5, 0), sum(s+5, 0);
    
    rep3(i, 3, s){
        dp[i] = (1 + sum[i-3]) % MOD;
        sum[i] = (sum[i-1] + dp[i]) % MOD;
    }
    cout << dp[s] << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
int main()
{

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
//  #ifdef ONLINE_JUDGE
//	    freopen("input1.txt","r",stdin);
//	    freopen("output1.txt","w",stdout);
//  #endif
int x;
cin >> x;
int a = x/500;
int first = x%500;
int rem=first/5;
int total=a*1000+rem*5;
cout << total;

  }


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <queue>
#include <climits>

using namespace std;

typedef long long ll;

int t;
string N;

ll compute(int lefti, int len, int k, int maxdigit, bool ismax) 
{
    if(k==0) return 1;
    if(len==0) return 0;
    if(maxdigit == 0) return compute(lefti+1, len-1, k, ismax ? N[lefti+1]-'0':9, ismax);
    ll ans = 0;
    for(int i=1;i<maxdigit;++i)
        ans += compute(lefti+1, len-1, k-1, 9, false);
    ans += compute(lefti+1, len-1, k-1, ismax ? N[lefti+1]-'0' : 9, ismax);
    ans += compute(lefti+1, len-1, k, 9, false);
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout); 
    int k;
    while (cin>>N>>k) {
        ll ans = 0;
        for(int i=1;i<(N[0]-'0');++i) 
            ans += compute(1, N.length()-1, k-1, 9, false);
        ans += compute(1, N.length()-1, k-1, N[1]-'0', true);
        ans += compute(1, N.length()-1, k, 9, false);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


int main() {
  long long a;
  cin>>a;
  vector<long long> vec(a);
  rep(i,a){
    cin>>vec.at(i);
  }
  long long dp[1000010];
  rep(i,1000010){
    dp[i]=1000000000;
  }
  dp[0]=0;
  for(long long i=1;i<a;i++){
    chmin(dp[i],dp[i-1]+abs(vec.at(i)-vec.at(i-1)));
    if(i>1){
      chmin(dp[i],dp[i-2]+abs(vec.at(i)-vec.at(i-2)));
    }
  }
  cout<<dp[a-1]<<endl;
}


Measured memory_bytes: 8960
/*
×¢Òâ·¶Î§£¡
short·¶Î§£º-32768~32767
unsigned short·¶Î§£º0~65535
int·¶Î§£º-2147483648~2147483647
uint·¶Î§£º0~4294967295
INT·¶Î§£º-9223372036854775808~9223372036854775807
UINT·¶Î§£º0~18446744073709551615
float·¶Î§£º-3.4e38~3.4e38£¬¾«¶È£º6~7Î»
double·¶Î§£º-1.7e308~1.7e308£¬¾«¶È£º15~16Î»
ldouble·¶Î§£º-1.2e4932~1.2e4932£¬¾«¶È£º18~19Î»
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
using namespace std;
void avoid(){}
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;

int n,m,a,b;

//Can calculate a^(Mod-2) quickly(O(log a)).
inline INT mitsfun(int di,int zhi)
{
	if(zhi==0)return 1;
	INT num=mitsfun(di,zhi/2);
	num=num*num%Mod;
	if(zhi%2)num=num*di%Mod;
	return num;
}

INT c1[100007];

int main()
{
	scanf("%d%d%d%d",&n,&m,&a,&b);
	INT cdi=n-a-1,num=1;
	for(int i=1;i<m;i++)
	{
		num=num*(i+cdi)%Mod*mitsfun(i,Mod-2)%Mod;
		if(i>=b)c1[i]=num;
	}
	cdi=a-1;
	num=1;
	INT cnt=c1[m-1];
	for(int i=m-2,j=1;i>=b;i--,j++)
	{
		num=num*(j+cdi)%Mod*mitsfun(j,Mod-2)%Mod;
		cnt=(cnt+(num*c1[i]%Mod))%Mod;
	}
	printf("%I64d\n",cnt);
	return 0;
}

Measured memory_bytes: 1152
N = int(input())
S = input()
cnt = 0
for i in range(1000):
    num = ''
    num += str(i // 100)
    num += str((i // 10) % 10)
    num += str(i % 10)
    j = 0
    for n in range(N):
        if S[n] == num[j]:
            j += 1
        if j == 3:
            break
    if j == 3:
        cnt += 1
print(cnt)

Measured memory_bytes: 41436
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int getIndex( string type )
{
	if ( type == "A" )
	{
		return 0;
	}
	else if ( type == "B" )
	{
		return 1;
	}
	else if ( type == "AB" )
	{
		return 2;
	}
	else
	{
		return 3;
	}
}

int main()
{
	int count[] = { 0, 0, 0, 0 };

	string buffer;
	while ( cin >> buffer )
	{
		for ( unsigned int i = 0; buffer.length(); i++ )
		{
			if ( buffer[i] == ',' )
			{
				buffer[i] = ' ';
				break;
			}
		}			

		int number;
		string type;

		istringstream( buffer ) >> number >> type;

		count[ getIndex( type ) ]++;
	}

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

	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;

ll rank1(vector< vector<ll> >& mat) {
	ll h = mat.size();
	ll w = mat[0].size();
	ll now = 0;
	for (ll i = 0; i < w; i++) {
		ll pivot = -1;
		for (ll j = now; j < h; j++) {
			if (mat[j][i] != 0) {
				pivot = j;
				break;
			}
		}
		if (pivot == -1) {
			continue;
		}
		if (pivot != now) {
			swap(mat[now], mat[pivot]);
		}
		// for (ll j = i + 1; j < w; j++) {
		//     mat[now][j] /= mat[now][i];
		// }
		for (ll j = now + 1; j < h; j++) {
			if (mat[j][i]) {
				for (ll k = i + 1; k < w; k++) {
					mat[j][k] ^= mat[now][k];
				}
			}
		}
		now++;
		if (now == h) {
			break;
		}
	}
	return now;
}

ll mpow(int n, int k, int p) {
	if (k == 0)return 1;
	if (k % 2)return 1LL * n * mpow(n, k - 1, p) % p;
	else {
		ll sub = mpow(n, k / 2, p);
		return 1LL * sub * sub% p;
	}
}

int main() {
	int n, m; cin >> n >> m;
	vector<vector<ll>> a(n);
	rep(i, 0, n) {
		a[i].resize(m);
		rep(j, 0, m) {
			cin >> a[i][j];
		}
	}
	int r = rank1(a);

	ll ans = (mpow(2, n + m - 1, MOD) - mpow(2, n + m - r - 1, MOD) + MOD) % MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 896
import sys
import math

lines = sys.stdin.readlines()
a1, b1 = map(int, lines[0].split())
a2, b2 = map(int, lines[1].split())
a3, b3 = map(int, lines[2].split())

dic = {1:0,2:0,3:0,4:0}

dic[a1] += 1
dic[b1] += 1
dic[a2] += 1
dic[b2] += 1
dic[a3] += 1
dic[b3] += 1

for k, v in dic.items():
  if 0 < v < 3:
    continue
  print('NO')
  exit(0)
print('YES')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int A,B,C;cin >> A >> B >> C;
    if(A + B + C >= 22){
        cout << "bust" << endl;
    }
    else cout << "win" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll n,k;
  cin>>n>>k;
  vi v(k); //個数メモ
  rep(i,k) v[i]=POW(k/(i+1),n);
  for(ll i=k-1;i>=0;i--){
    REP(j,2,k/(i+1)+1){
      v[i]-=v[(i+1)*j-1];
    }
  }
  //outv(v);
  ll ans=0;
  rep(i,k) ans=(ans+(i+1)*v[i])%mod;
  out(ans);
}

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


Measured memory_bytes: 3912
object Main extends App {
  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val count = Array.tabulate(n * 2){_ ⇒ 0}
  for (_ ← 0 until m){
    val Array(a, l) = readLine.trim.split(' ').map(_.toInt)
    count(a) += 1
    count(a + l) -= 1
  }
  var bias = 0
  for (x ← count){
    if (bias + x >= 0) bias += x
  }
  count(0) += bias
  for (i ← count.indices.tail){
    count(i) += count(i - 1)
  }
  val length = Array.tabulate(n){_ ⇒ 0}
  for (i ← length.indices){
    if (count(i) != 0 || count(i + n) != 0) length(i) = 1
  }
  for (i ← 1 to 2 * n){
    if (length(i % n) != 0) {
      length(i % n) = length((i - 1) % n) + 1
    }
  }
  val separated = length.indices.filter(i ⇒ length(i) != 0 && length((i + 1) % n) == 0)
  println(if (separated.nonEmpty) separated.map(length).groupBy(i ⇒ i).mapValues(_.length).toArray.sortBy(_._1)(Ordering.Int.reverse).map{case (len, c) ⇒ s"$len $c"}.mkString("\n") else s"$n 1")

  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 44524
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while((line = br.readLine())  != null) {
			String[] arrays = line.split(" ");
			int a = Integer.parseInt(arrays[0]);
			int b = Integer.parseInt(arrays[1]);
			System.out.println(a+b);
		}
	}
}

Measured memory_bytes: 17056
package main
  
import (
    "fmt"
)

func main() {
    var a, b, c, d, e, k int
    fmt.Scan(&a, &b, &c, &d, &e, &k)
    if e-a <= k {
        fmt.Println("Yay!")
    } else {
        fmt.Println(":(")
    }
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	switch(a) {
	case 5:
		if (b == 7 && c == 5) {
			cout << "YES" << endl;
		}
		else if (b == 5 && c == 7) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		break;
	case 7:
		if (b == 5 && c == 5) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		break;
	default:
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=200005;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
int n,m;
int tax[N],a[N],c[N],tot=0;
int main(){
	n=tot=read(),m=read();
	for (int x=1;x<=n;x++){
		a[x]=read();
		if (a[x]-tax[a[x]]>0)
			tot-=c[a[x]-tax[a[x]]]++==0;
		tax[a[x]]++;
	}
	while (m--){
		int x=read(),y=read();
		tax[a[x]]--;
		if (a[x]-tax[a[x]]>0)
			tot+=--c[a[x]-tax[a[x]]]==0;
		a[x]=y;
		if (a[x]-tax[a[x]]>0)
			tot-=c[a[x]-tax[a[x]]]++==0;
		tax[a[x]]++;
		printf("%d\n",tot);
	}
	return 0;
}

Measured memory_bytes: 4348
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define forn(i,n) for(int i=0;i<(n);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define fordec(i,a,b) for(int i=(a);i>=(b);i--)
#define vi vector<int>
#define vl vector<ll>
#define vd vector<double>
#define vs vector<string>
#define pb push_back
#define vpi vector<pair<int, int>
#define vpl vector<pair<ll, ll>>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////

int main()
{
    ios::sync_with_stdio(0);
	cin.tie(0);
    int a, b; cin >> a >> b;
    int count = 0, cur = 1;
    while (cur < b) {
        cur += a - 1;
        count++;
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main(void){
    
    int N, ans=0;
    string S;
    
    cin >> N >> S;
    
    for(int i = 0; i < S.length() ;){
        if(S[i] == 'O'){
            if(S[i+1] == 'X'){ 
            ans++;
            i+=2;
            }
            else i++;
        }
        else if(S[i] == 'X'){
            if(S[i+1] == 'O'){ 
            ans++;
            i+=2;
            }
            else i++;
        }
    }
    
    std::cout << ans << std::endl;
    
    
}



Measured memory_bytes: 3324
def SumOfTheDigit(n):
	sum=0
	while not n==0:
		mod = n%10
		sum = sum + mod
		n = n//10
	return sum

N,A,B = map(int,input().split())
ans = 0
for i in range(N+1):
	test = int(SumOfTheDigit(i) )
	if A <= test <=B:
		ans = ans + i
print(ans)

Measured memory_bytes: 3060
n = int(input())
ac,wa,tle,re = 0,0,0,0
for i in range(n):
    case = input()
    if case == 'AC':
        ac += 1
    elif case == 'WA':
        wa += 1
    elif case == 'TLE':
        tle += 1
    elif case == 'RE':
        re += 1

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 2e9;

int main() {
  int a,b;
  cin >> a >> b;
  cout << a*b/2 << endl;
}

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

using namespace std;

main(){
	int a,b,c,d,A=0,B=0;
	cin >>a >>b >>c >>d;
	A=a+b+c+d;
	int e,f,g,h;
	cin >>e >>f >>g >>h;
	B=e+f+g+h;
	if (A>B){
	printf("%d\n",A);
	}
	else if (A<B){
	printf("%d\n",B);
	}
	else {
		printf("%d\n",A=B);
	}
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    string as, bs, cs;
    cin >> as >> bs >> cs;
    queue<char> a, b, c;
    rep(i, as.size()) a.push(as.at(i));
    rep(i, bs.size()) b.push(bs.at(i));
    rep(i, cs.size()) c.push(cs.at(i));
    char prev = ' ';
    char next = 'a';
    while (next)
    {
        prev = next;
        if (next == 'a')
        {
            next = a.front();
            a.pop();
        }
        else if (next == 'b')
        {
            next = b.front();
            b.pop();
        }
        else if (next == 'c')
        {
            next = c.front();
            c.pop();
        }
    }

    cout << (char)toupper(prev) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
signed main(void)
{
	int n,d;
	cin>>n>>d;
	int ans=0;
	while(true)
	{
		n-=d*2+1;
		++ans;
		if(n<=0)
			break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  while(1){
  int n,score=0,sum=0;

  cin >> n;
  if(n==0)break;

  for(int i=0;i<(n/4);i++){
    cin>>score;
    sum+=score;
}
  cout << sum<<endl;
  }
  return 0;
}

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

int main(){
	int n,i,j,sum,ans=10000000;
	cin>>n;
	int a[n+1];
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=-101;i<=101;i++){
		sum=0;
		for(j=1;j<=n;j++)
			sum+=(a[j]-i)*(a[j]-i);
		ans=min(sum,ans);	
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int l;
int m[12], n[12];

int main() {
	while (cin >> l, l) {
		REP(i, 12) scanf("%d %d", m + i, n + i);
		
		int ans = -1, sum = 0;
		REP(i, 12) {
			sum += m[i] - n[i];
			if (sum >= l) { ans = i + 1; break; }
		}
		
		if (ans == -1) puts("NA");
		else cout << ans << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3112
n,m,c=map(int,input().split())
b_list=list(map(int,input().split()))

cnt=0

for i in range(n):
    sum=0
    a_list=list(map(int,input().split()))
    for j in range(m):
        sum+=a_list[j]*b_list[j]
    sum+=c
    if sum>0:
        cnt+=1
        
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define P push
#define S second
#define F first
using namespace std;
typedef long long ll;

ll num[10009];
int main() {
    ll n,x;
    cin>>n>>x;
    x=min(x,n-x);
    ll y=n-x;

    ll res=0;
    while(true){
        res+=(y/x)*3*x;
        ll c=y%x;
        ll c1=x;
        y=max(c1,c);
        x=min(c1,c);
        if(x==0||y1==0)break;
    }
    cout<<res<<endl;


}


Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())

A = sorted(map(int, input().split()), reverse=True)
B = sorted(map(int, input().split()), reverse=True)
C = sorted(map(int, input().split()), reverse=True)

ABC = []
for a in range(X):
    for b in range(Y):
        if (a + 1) * (b + 1) > K:
            break
        for c in range(Z):
            if (a + 1) * (b + 1) * (c + 1) > K:
                break
            ABC.append(A[a] + B[b] + C[c])

ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])


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

using namespace std;

int main() {
	int n;
	int a, b, c;
	int dp[3], v[3];
	cin >> n;

	scanf("%d%d%d", &dp[0], &dp[1], &dp[2]);  

	for (int i=1; i<n; i++) {
		scanf("%d%d%d", &a, &b, &c);

		v[0] = a + max(dp[1], dp[2]);
		v[1] = b + max(dp[0], dp[2]);
		v[2] = c + max(dp[0], dp[1]);

		dp[0] = v[0];
		dp[1] = v[1];
		dp[2] = v[2];
	}

	cout << max(max(dp[0], dp[1]), dp[2]) << endl;

	return 0;
}

Measured memory_bytes: 256
s = input()
s = '0' + s
odd  = ['R','U','D']
even = ['L','U','D']

flag = True

for i in range(1,len(s)):
  if i%2!=0 and s[i] not in odd:#奇数
    flag = False
  if i%2==0 and s[i] not in even:#偶数
    flag = False
    
if flag==True: print('Yes')
else: print('No')

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	ll N, K;

	cin >> N >> K;

	if( K <= (N - 1)*(N - 2) / 2 ){
		int M = N * (N - 1) / 2 - K;
		vector<pii> ans;
		rep(i,N) reps(j,i+1,N) if( ans.size() < M ) ans.emplace_back(i, j);

		cout << M << endl;
		for(auto t: ans) cout << t.X + 1 << " " << t.Y + 1 << endl;
	}else{
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 384
// AtCoder Grand Contest 014
// B - Unplanned Queries

#include <cstdio>
#include <cstring>
#define MAX_N 100000
using namespace std;
typedef long long int ll;


int N, M;
int appear[MAX_N];

int main() {

  int a;

  scanf("%d%d", &N, &M);
  memset(appear, 0, sizeof(appear));
  for (int i = 0; i < 2 * M; i++) {
    scanf("%d", &a);
    appear[a - 1]++;
  }

  for (int i = 0; i < N; i++) {
    if (appear[i] % 2 != 0) {
      printf("NO\n");
      return 0;
    }
  }

  printf("YES\n");
  return 0;

  return 0;

}




Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

long *tree[100001];

int main(void) {

  long n,u,v;
  scanf("%ld %ld %ld", &n, &u, &v);
  long tree_s[n+1];
  for (long i = 0; i <= n; i++) {
    tree_s[i] = 0;
  }
  long a,b;
  for (long i = 0; i < n-1; i++) {
    scanf("%ld %ld", &a, &b);
    tree[a] = realloc(tree[a], sizeof(long)*(tree_s[a]+1));
    tree[a][tree_s[a]] = b;
    tree_s[a]++;
    tree[b] = realloc(tree[b], sizeof(long)*(tree_s[b]+1));
    tree[b][tree_s[b]] = a;
    tree_s[b]++;
  }
  int visited[n+1];
  long depth_u[n+1],depth_v[n+1];
  for (long i = 0; i <= n; i++) {
    visited[i] = 0;
    depth_u[i] = 0;
    depth_v[i] = 0;
  }
  visited[u] = 1;
  long queue[n];
  queue[0] = u;
  long start = 0, end = 0, tail = 0;
  long cur,next;
  while (tail < n-1) {
    for (long i = start; i <= end; i++) {
      cur = queue[i];
      for (long j = 0; j < tree_s[cur]; j++) {
        next = tree[cur][j];
        if (visited[next] == 1) {
          continue;
        }
        visited[next] = 1;
        depth_u[next] = depth_u[cur]+1;
        tail++;
        queue[tail] = next;
      }
    }
    start = end+1;
    end = tail;
  }
  for (long i = 0; i <= n; i++) {
    visited[i] = 0;
  }
  visited[v] = 1;
  queue[0] = v;
  start = 0; end = 0; tail = 0;
  while (tail < n-1) {
    for (long i = start; i <= end; i++) {
      cur = queue[i];
      for (long j = 0; j < tree_s[cur]; j++) {
        next = tree[cur][j];
        if (visited[next] == 1) {
          continue;
        }
        visited[next] = 1;
        depth_v[next] = depth_v[cur]+1;
        tail++;
        queue[tail] = next;
      }
    }
    start = end+1;
    end = tail;
  }
  long move;
  long max = 0;
  for (long i = 1; i <= n; i++) {
    if (depth_u[i] >= depth_v[i]) {
      continue;
    }
    move = depth_v[i]-1;
    if (move > max) {
      max = move;
    }
  }
  printf("%ld\n", max);

  return 0;
}

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

#define ll long long
#define mod 1000000007
#define pii pair<ll,ll>

#define debug(a) { cout << #a << " = " << a << endl;}

const int maxn = 2e5+1;
ll arr[maxn],arr1[maxn], n, m, t, k;
unordered_map<ll,ll> u;

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

ll d(int i) {
    return arr[n-1] - arr[i];
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>m;
        arr1[i]=m;
        if (i==0) arr[i] = m;
        else arr[i] = m+arr[i-1];
    }
    ll ans=0;
    for (int i=0;i<n;i++) {
        ans = (ans + ((arr1[i]%mod)*(d(i)%mod)))%mod;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 6764
#include <bits/stdc++.h>  // ver2.2.2
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ

int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  string s;
  cin >> s;
  int l = s.size();
  int ans = l*(l-1)/2;
  Vi a(26);
  rep(i,0,l){
    a[s[i]-'a']++;
  }
  
  rep(i,0,26){
    if(a[i]!=0){
      ans -= a[i]*(a[i]-1)/2;
    }
  }
  cout << ans+1 << endl;
  return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

vector<int> par(110000);
vector<ll> mem(110000);

void init(int n){
  for(int i = 0; i < n; i++){
   par.at(i) = i;
   mem.at(i) = 1;
  }
}

int root(int x){
  if(par.at(x) == x) return x;
  return par.at(x) = root(par.at(x));
}

void unite(int x, int y){
  if(root(x) == root(y)) return;
  mem.at(root(y)) += mem.at(root(x));
  mem.at(root(x)) = 0;
  par.at(root(x)) = root(y);
}

bool same(int x, int y){
  return root(x) == root(y);
}

int main(){
  ll N, M;
  cin >> N >> M;
  init(N);
  vi A(M), B(M);
  for(int i = 0; i < M; i++){
    cin >> A.at(i) >> B.at(i);
    A.at(i)--; B.at(i)--;
  }

  stack<ll> result;
  ll fuben = N*(N-1)/2;
  result.push(fuben);
  for(int i = M-1; i >= 1; i--){
    if(!same(A.at(i), B.at(i))){
      fuben -= mem.at(root(A.at(i))) * mem.at(root(B.at(i)));
      unite(A.at(i), B.at(i));
    }
    result.push(fuben);
  }

  while(!result.empty()){
    ll res = result.top(); result.pop();
    cout << res << endl;
  }
}


Measured memory_bytes: 4012