akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b,k;
  cin >> a >> b >> k;
  map<int,int> mp;
  rep(i,k){
    if(a+i<a||a+i>b) continue;
    mp[a+i];
  }
  rep(i,k){
    if(b-k+i+1<a||b-k+i+1>b) continue;
    mp[b-k+i+1];
  }
  for(auto p:mp){
    cout << p.first << endl;
  }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int ara[3][3];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> ara[i][j];
        }
    }
    map<int, int> m;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int test;
        cin >> test;
        m[test] = 1;
    }

    for (int i = 0; i < 3; i++)
    {
        bool ans = true;
        for (int j = 0; j < 3; j++)
        {
            if (m[ara[i][j]] == 0)
                ans = false;
        }
        if (ans)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    for (int i = 0; i < 3; i++)
    {
        bool ans = true;
        for (int j = 0; j < 3; j++)
        {
            if (m[ara[j][i]] == 0)
                ans = false;
        }
        if (ans)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (m[ara[0][0]] * m[ara[1][1]] * m[ara[2][2]] == 1)
    {
        cout << "Yes" << endl;
        return 0;
    }
    if (m[ara[0][2]] * m[ara[1][1]] * m[ara[2][0]] == 1)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


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

int main() {
    ll A;
    ld B;
    cin >> A >> B;
    ll b = (ll)(B * 100.0 + 0.5L);
    cout << A * b / 100LL << endl;
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

#define MAX_N (1<<18)

struct segtree{
    int n;
    ll dat[2*MAX_N-1]; //(1<<17) = 130000

    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        for(int i = 0; i < 2*n-1; i++) dat[i] = 0;
    }

    void update(int k, ll a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = max(dat[k*2+1], dat[k*2+2]);
        }
    }

    ll query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return dat[k];
        else{
            ll vl = query(a,b,k*2+1,l,(l+r)/2);
            ll vr = query(a,b,k*2+2,(l+r)/2,r);
            return max(vl, vr);
        }
    }
} seg;

ll n;
ll h[200000], a[200000];


int main() {
    cin >> n;
    rep(i,n) cin >> h[i];
    rep(i,n) cin >> a[i];
    seg.init(n);
    rep(i,n) {
        ll pre = seg.query(0, h[i], 0, 0, seg.n);
        seg.update(h[i]-1, pre+a[i]);
    }
    cout << seg.query(0, n, 0, 0, seg.n) << endl;
}



Measured memory_bytes: 7424
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    bool x;
    cin >> x;

    cout << (x == false) << "\n";

    return 0;
}



Measured memory_bytes: 3624
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

char op3[][10]={"aab","d.b","dcc"};
char op4[][10]={"aacd","bbcd","cdaa","cdbb"};
char op5[][10]={"aabee","d.bff","dccgg","efg..","efg.."};
char op7[][10]={"aabbcc.","dde...a","g.e...a","gff...b","...ddeb","...g.ec","...gffc"};

int n;
char ans[1111][1111];
int main()
{
	scanf("%d",&n);
	if(n==2)puts("-1");
	else if(n==3)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)putchar(op3[i%3][j%3]);
			puts("");
		}
	}
	else if(n%2==0)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				int val=(i/2+j/2)%(n/2);
				if(val==0)
				{
					if(i%2==0)putchar('a');
					else putchar('b');
				}
				else if(val==1)
				{
					if(j%2==0)putchar('c');
					else putchar('d');
				}
				else putchar('.');
			}
			puts("");
		}
	}
	else
	{
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)ans[i][j]='.';
		for(int k=0;k+4<n;k+=4)
		{
			for(int i=0;i<4;i++)for(int j=0;j<4;j++)ans[i+k][j+k]=op4[i][j];
		}
		if(n%4==1)
		{
			int k=(n-5);
			for(int i=0;i<5;i++)for(int j=0;j<5;j++)ans[i+k][j+k]=op5[i][j];
		}
		else
		{
			int k=(n-7);
			for(int i=0;i<7;i++)for(int j=0;j<7;j++)ans[i+k][j+k]=op7[i][j];
		}
		for(int i=0;i<n;i++)printf("%s\n",ans[i]);
	}
	return 0;
}

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

int dp[101000];

int main(){

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

	memset(dp,0,sizeof dp);
	dp[0]=0;
	for(int i=1;i<n;++i){
		int op1 = INT_MAX,op2=INT_MAX;
		if(i>=1){
			op1 = abs(a[i]-a[i-1]) + dp[i-1];
		}if(i>=2){
			op2 = abs(a[i]-a[i-2]) + dp[i-2];
		}
		dp[i]=min(op1,op2);
	}
	
	printf("%d\n",dp[n-1]);

	return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int N, K; cin >> N >> K;
    int ans = 0;
    rep(i, N) {
        int x; cin >> x;
        int dist = min(x, abs(K - x));
        ans += 2 * dist;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int S;
    std::cin >> S;
    int h = S/3600;
    int m = (S-h*3600)/60;
    int s = S-h*3600-m*60;
    std::cout << h << ":" << m << ":" << s << std::endl;

    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = (1e+9) + 7;
const ll MAX_N = 100010;
typedef pair<ll,ll> P;

int main() {
    cin >> S;
    N = S.size();
    ll r = 1, l = 0;
    char now,last=S[0];
    vec ans(N,0),temp(2,0);
    temp[0] = 1;
    ll here;
    S.push_back('R');
    reps(i,1,N+1){
        now = S[i];
        if(last == 'R' && now == 'L'){
            here = i;
        }else if(last == 'L' && now == 'R'){
            ans[here-1] = temp[(here-1)&1];
            ans[here] = temp[here&1];
            temp[0] = temp[1] = 0;
        }
        ++temp[i&1];
        last = now;
    }
    rep(i,N) cout<<ans[i]<<' ';
    cout<<endl;
}


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

int main(){
    int a, p;
    cin >> a >> p;
    printf("%d\n", (a*3+p)/2);
    return 0;
}

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

using namespace std;

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

  vector<int> a;
  int sum = 0;
  for(int i = 0;i < N;i++){
    int b;
    cin >> b;
    sum += b;
    a.push_back(b);
  }

  int h1 = (sum/N)*N;
  int h2 = (sum/N + 1)*N;
  int h = sum - h1 < h2 - sum ? (sum/N) : (sum/N + 1);

  int ans = 0;
  for(int i = 0;i < N;i++){
    ans += (a[i] - h)*(a[i] - h);
  }
  std::cout << ans << std::endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;

#define sync std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define loopi(n) for(int i=0;i<n;i++)
#define loopj(n) for(int j=0;j<n;j++)
#define loop(a,b,c) for(int i=a;i<=b;i=i+c)

#define     deb(x)      cout<<#x<<"="<<x<<endl
#define     all(x)      (x).begin(),(x).end()
#define     reset(a)    memset(a,0,sizeof(a))
#define     sz(x)       ((int)(x.size()))
#define     pb          push_back
#define     pf          push_front
#define     pob	        pop_back
#define     pof         pop_front
#define     ins         insert
#define     F           first
#define     S           second
#define     mkp         make_pair
#define     mkt         make_tuple
#define     bitcount(x) __builtin_popcountll(x)
#define     gcd(a,b)    (__gcd(a,b))
#define     lcm(a,b)    ((a*b)/gcd(a,b))
#define PI 3.1415926535897932384626
 
const int mod = 1e9+7;

//============================================//

void solve()
{
	string s,t;
	cin>>s>>t;
	
	int ans=INT_MAX;
	int l1=s.length(),l2=t.length();
	
	for(int i=0;i<l1-l2+1;i++)
	{
		int c=0;
		for(int j=0;j<l2;j++)
			if(t[j]==s[i+j])
				c++;
		c=l2-c;
		ans=min(ans,c);
	}
	cout<<ans;
}
int main() 
{
	sync;

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

Measured memory_bytes: 3656
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7')yes;
	else no;
}












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

typedef long long ll;
typedef long long int lli;
const int MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < n; i++)

using namespace std;

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

	string N;
	cin >> N;

	for (int i = 0; i < 3;i++) {
		if (N[i] == N[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
}

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

using namespace std;

typedef long long ll;

const int nax = 1e7+7;
const int MOD = 1e9+7;

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

    double ans = 0;

    for(int i=1; i<=n; i++){
        double tmp = k;
        double curr = 1;
        while(tmp>i){
            tmp/=2;
            curr/=2;
        }
        ans += curr;
    }

    ans /= n;

    cout<<setprecision(10)<<ans<<endl;

    return 0;
}

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

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

    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(a > d){
            x++;
            continue;
        }
        int j = 1, tmp = a;;
        while(true){
            if(a > d){
                break;
            }
            x++;
            a = (tmp * j) + 1;
            //cout << "a:" << a << endl;
            j++;
        }
        //cout << "x:" << x << endl;
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import heapq
from collections import defaultdict

N=int(input())
A=[0]+list(map(int,input().split()))

def Nextstring(nowlength,nextlength):
    if nextlength>nowlength:
        while -USELIST[0]>nowlength:
            dis=-heapq.heappop(USELIST)
            del NOWSTR[dis]
        nowlength=nextlength

    else:
        while -USELIST[0]>nextlength:
            dis=-heapq.heappop(USELIST)
            del NOWSTR[dis]

        if NOWSTR[nextlength]<mid-1:
            
            if NOWSTR[nextlength]==0:
                NOWSTR[nextlength]+=1
                heapq.heappush(USELIST,-nextlength)
                nowlength=nextlength
            else:
                NOWSTR[nextlength]+=1
                nowlength=nextlength

        else:
            klength=nextlength
            while NOWSTR[klength]==mid-1:
                if klength in NOWSTR:
                    del NOWSTR[klength]
                klength-=1
                if mid!=1:
                    dis=-heapq.heappop(USELIST)
                    if dis in NOWSTR:
                        del NOWSTR[dis]

                if klength==0:
                    return -1

            if NOWSTR[klength]==0:
                NOWSTR[klength]+=1
                heapq.heappush(USELIST,-klength)
                nowlength=nextlength

            else:
                NOWSTR[klength]+=1
                nowlength=nextlength

    return 0

for i in range(N):
    if A[i]>=A[i+1]:
        MIN=2
        break
else:
    print(1)
    sys.exit()

from collections import Counter
MAX=max(Counter(A).values())+1

while MIN!=MAX:
    mid=(MIN+MAX)//2
    nowlength=0
    NOWSTR=defaultdict(int)
    USELIST=[10**6]

    for i in range(N):

        if Nextstring(A[i],A[i+1])==-1:
            MIN=mid+1
            break
        #print(mid,NOWSTR,USELIST)
    else:
        MAX=mid

print(MIN)

Measured memory_bytes: 107988
using System;
 
namespace _135C
{
    class Program
    {
        static void Main(string[] args){
            int N = int.Parse(Console.ReadLine());
            long[] A = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            long[] B = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            long winNum = 0;
            for(int i = 0; i < N ; i++){
                if(A[i] >= B[i]){
                    winNum += B[i];
                }else{
                    if(A[i]+A[i+1] >= B[i]){
                        winNum += B[i];
                        A[i+1] = A[i+1] - (B[i] - A[i]);
                    }else{
                        winNum += A[i] + A[i+1];
                        A[i+1] = 0;
                    }
                }
            }
            Console.WriteLine(winNum);
        }
    }
}

Measured memory_bytes: 35292
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	ll n, t;
	cin >> n >> t;

	vector<ll> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	ull s = t;
	for (int i = 1; i < n; i++)
	{
		if (a.at(i) - a.at(i - 1) > t)
		{
			s += t;
		}
		else
		{
			s += a.at(i) - a.at(i - 1);
		}
	}

	cout << s << endl;
}


Measured memory_bytes: 1792
num = int(input())
a = []
[a.append(int(input())) for _ in range(num)]
minn = a[0]
maxn = (10 ** 9) * -1
for i in range(1,len(a)):
  maxn = max(maxn,a[i] - minn)
  minn = min(minn,a[i])
print(maxn)


Measured memory_bytes: 15156
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
vector<ll> vec,n2;
vector<P> pv;
vector<bool> kk;
int ma_2(ll a){
  int ret=0;
  ll c=1;
  while(c<=a){
    c*=2;
    ret++;
  }
  return ret;
}
int main(){
  int n;
  cin>>n;
  ll k;
  cin>>k;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    vec.push_back(a);
  }
  sort(vec.begin(),vec.end());
  int max_n=max(ma_2(k),ma_2(vec[n-1]));
  pv.resize(max_n+1,P(0,0));
  for(int i=0;i<n;i++){
    ll nm=vec[i];
    for(int j=0;j<max_n;j++){
      if(nm%2==0) pv[j].first++;
      else pv[j].second++;
      nm/=2;
    }
  }
  n2.push_back(1);
  kk.resize(max_n+1,true);
  ll k2=k;
  for(int i=0;i<max_n;i++){
    n2.push_back(n2[i]*2);
    if(k2%2==1) kk[i]=true;
    else kk[i]=false;
    k2/=2;
  }
  ll dp[2][2]={0};
  int id=max_n-1;
  if(kk[id]){
    dp[0][0]=pv[id].second*n2[id];
    dp[0][1]=pv[id].first*n2[id];
  }
  else{
    dp[0][1]=pv[id].second*n2[id];
  }
  for(int i=1;i<max_n;i++){
    int idx=max_n-i-1;
    if(dp[0][0]>0) dp[1][0]=dp[0][0]+max(pv[idx].first,pv[idx].second)*n2[idx];
    if(kk[idx]){
      dp[1][0]=max(dp[1][0],dp[0][1]+pv[idx].second*n2[idx]);
      dp[1][1]=dp[0][1]+pv[idx].first*n2[idx];
    }
    else{
      dp[1][1]=dp[0][1]+pv[idx].second*n2[idx];
    }
    dp[0][0]=dp[1][0];
    dp[0][1]=dp[1][1];
    dp[1][0]=0;
    dp[1][1]=0;
  }
  cout<<max(dp[0][0],dp[0][1])<<endl;
}


Measured memory_bytes: 1400
#include<stdio.h>
int main() {
	long long int X,Y,A,i;
	int result = 1;
	scanf("%lld%lld", &X, &Y);
	A = X;
	for (i = 0; i < 100; i++) {

		A = 2 * A;

		if (A <= Y) {
			result++;
		}
		else {
			printf("%d", result);
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n, cols;
    cin >> n >> cols;
    vvint d(cols, vint(cols)), c(n, vint(n));
    rep(i, cols) rep(j, cols) cin >> d[i][j];
    rep(i, n) rep(j, n)
    {
        cin >> c[i][j];
        c[i][j]--;
    }
    map<int, int> m1, m2, m3;
    rep(i, n) rep(j, n)
    {
        int k = (i + j) % 3;
        int now = c[i][j];
        if (k == 0)
            m1[now]++;
        if (k == 1)
            m2[now]++;
        if (k == 2)
            m3[now]++;
    }

    ll ans = 1LL << 60;
    rep(c1, cols) rep(c2, cols) rep(c3, cols)
    {
        if (c1 == c2 || c2 == c3 || c3 == c1)
        {
            continue;
        }
        ll now = 0;
        for (P p : m1)
        {
            now += d[p.first][c1] * p.second;
        }
        for (P p : m2)
        {
            now += d[p.first][c2] * p.second;
        }
        for (P p : m3)
        {
            now += d[p.first][c3] * p.second;
        }

        chmin(ans, now);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

int main(){
    int K;
    cin>>K;
    long long sum=0;
    for(int i=1;i<K+1;i++)
        for(int j=1;j<K+1;j++)
            for(int t=1;t<K+1; t++)
                sum=sum+fn(fn(i,j),t);
    
    cout<<sum;
}


Measured memory_bytes: 3612
/**
 *     author: qodjf
 *     created: 04.22.2020 00:11:45
 */
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;

ll mul(ll a, ll b) { return a * b % MOD; }

ll add(ll a, ll b) { return (a + b) % MOD; }

ll sub(ll a, ll b) { return (a - b + MOD) % MOD; }

ll my_pow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1) r = mul(r, a);
    a = mul(a, a);
    b >>= 1;
  }
  return r;
}

ll my_inv(ll a) { return my_pow(a, MOD - 2); }

namespace Comb {
const int MAXK = 2e6 + 5;
int fac[MAXK], inv_fac[MAXK];

void init() {
  fac[0] = inv_fac[0] = 1;
  for (int i = 1; i < MAXK; ++i) {
    fac[i] = mul(fac[i - 1], i);
    inv_fac[i] = my_inv(fac[i]);
  }
}

int C(int a, int b) {
  return mul(fac[a], mul(inv_fac[b], inv_fac[a - b]));
}

}  // namespace Comb

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

  int r1, r2, c1, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  Comb::init();
  ll ans = 0;
  ll prev = 0;
  int lr = r1, lc = c1, rr = r1, rc = c1;
  for (int s = r1 + c1; s <= r2 + c2; s++) {
    ll cur = mul(prev, 2);
    if (lc == c1) {
      cur = add(cur, Comb::C(s - 1, lr));
    } else {
      cur = sub(cur, Comb::C(s - 1, lr));
    }
    if (rr == r1) {
      cur = add(cur, Comb::C(s - 1, rc));
    } else {
      cur = sub(cur, Comb::C(s - 1, rc));
    }

    if (lr < r2) {
      lr++;
    } else {
      lc++;
    }
    if (rc < c2) {
      rc++;
    } else {
      rr++;
    }

    ans = add(ans, cur);
    prev = cur;
  }
  cout << ans << endl;
}


Measured memory_bytes: 15872
let n, m, c = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let bs = Array.init m @@ fun _ -> Scanf.scanf " %d" (+) 0
let abss = Array.init n @@ fun _ -> Array.init m @@ fun i -> Scanf.scanf " %d" @@ fun a -> a * bs.(i)
let _ = Array.fold_left (fun ans ab_s -> ans + if Array.fold_left (+) c ab_s > 0 then 1 else 0) 0 abss |> Printf.printf "%d\n"

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define _GLIBCXX_DEBUG


signed main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  int ans = 0;
  
  rep(i, N-1) {
    if((A[i]%2) * A[i+1] >= 1) {
      A[i]--;
      A[i+1]--;
      ans++;
    }
  }
  
  rep(i,N) {
    while(A[i] >= 2) {
      A[i] -= 2;
      ans++;
    }
  }
  
  
  cout << ans << endl;


}

Measured memory_bytes: 1024
fun main(args : Array<String>) {
    var N = readLine()!!.toInt()

    val BASE = -2

    if (N == 0) {
        println('0')
    }

    var S = ""
    while (N != 0) {
        var rest = N % BASE
        S = Math.abs(rest).toString() + S
        N = N / BASE
        if (rest < 0) {
            N++
        }
    }

    println(S)
}


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

int main(){
  int s, i;
  cin >> s;
  std::unordered_map<int, int> mem(1000000);
  
  for(i = 0; true; i++){
    if( !mem.insert({s,1}).second ) break;
    s = (s % 2 == 0) ? (s / 2): (s * 3 + 1);
  }
  cout << i+1 << endl;
  return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define pr printf
#define sc scanf
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef long double ld;
int n, m, a, b;
bool comp1(ii a, ii b) {
    if(a.se != b.se) return a.se < b.se;
    return a.fi > b.fi;
}
vector<ii> li;
map<ii, int> ma;
void insert(ii pa) {
    if (ma.count(pa)) ma[pa]++;
    else ma[pa] = 1;
}
void remove(ii pa) {
    if(ma.count(pa)) {
        //cout << "aaa"<< "\n";
        ma[pa]--;
        if(ma[pa] == 0) ma.erase(pa);
        //cout << "bbb"<< "\n";
    }
}
ii pegaMax() {
    map<ii, int>::iterator it = ma.end(); it--;
    return it->fi;
}
int main () {
    sc("%d %d", &n, &m);
    for(int i = 0; i < n; i++) {
        sc("%d %d", &a, &b);
        li.pb({b, a});
    }
    sort(li.begin(), li.end(), comp1);
    int i = 0, j = 0;
    ll resp = 0LL;
    
    while(i < m) {
        while(j < n && li[j].se <= i+1) {
            insert(li[j]);
            j++;
        }
        //cout << "size: " << ma.size() << "\n";
        if(ma.size() > 0) {
            ii pa = pegaMax();
            //cout << pa.fi << " " << pa.se << "\n";
            resp += pa.fi;
            remove(pa);
        }
        i++;
    }
    pr("%lld\n", resp);
    return 0;
}


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

int main() {
    int N,M,C,ans;
    int B[30],A[30][30];
    cin >>N>>M>>C;
    for(int i=0;i<M;i++) cin >> B[i];
    for(int i=0;i<N;i++) {
      for(int j=0;j<M;j++){
        cin>>A[i][j];
      }
    }
    for(int i=0;i<N;i++) {
      int tmp=C;
      for(int j=0;j<M;j++){
        tmp+=A[i][j]*B[j];
      }
      if(tmp>0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
a,b,c,x,y=map(int, input().split())
if x>y:
  print(min(a*x+b*y,2*c*y+a*(x-y),2*c*x))
else:
  print(min(a*x+b*y,2*c*x+b*(y-x),2*c*y))

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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n, m;
int p[100001], y[100001];
int num[100001];
string ans[100001];

string sol(tuple<int,int,int> a) {
  int nowy, nown, index;
  tie(nowy, nown, index) = a;
  string nn = to_string(nown);
  string yy = to_string(nowy);
  while (nn.size() < 6) {
    nn = "0" + nn;
  }
  while (yy.size() < 6) {
    yy = "0" + yy;
  }
  return nn + yy;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  if (stream2 == NULL) return 0;
#endif
  vector<tuple<int,int,int> > v;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> p[i] >> y[i];
    p[i]--;
    v.push_back(make_tuple(y[i], p[i], i));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) num[i] = 1;
  for (int i = 0; i < m; i++) {
    tuple<int,int,int> tmp = make_tuple(num[get<1>(v[i])], get<1>(v[i]) + 1, i);
    ans[get<2>(v[i])] = sol(tmp);
    num[get<1>(v[i])]++;
  }
  for (int i = 0; i < m; i++) {
    cout << ans[i] << endl;
  }
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  fclose(stream2);
#endif
  return 0;
}

Measured memory_bytes: 10100
class UnionFind():
    "Either 0-indexed or 1-indexed"

    __slots__ = ["parent"]

    def __init__(self, size):
        self.parent = [-1] * (size + 1)
    
    def find(self, a):
        path = []
        while self.parent[a] > 0:
            path.append(a)
            a = self.parent[a]
        for child in path:
            self.parent[child] = a
        return a

    def union(self, a, b):
        a = self.find(a)
        b = self.find(b)

        if a == b:
            return
        else:
            if self.parent[a] == self.parent[b]:
                self.parent[a] = b
                self.parent[b] -= 1
            elif self.parent[a] < self.parent[b]: #aのほうが大きい
                self.parent[b] = a
            else:
                self.parent[a] = b #bのほうが大きい
        
    def same(self, a, b):
        return self.find(a) == self.find(b)


def main():
    import sys
    input = sys.stdin.buffer.readline
    N, Q = map(int, input().split())
    tuvs = map(int, sys.stdin.buffer.read().split())
    ans = []
    uf = UnionFind(N)
    for t, u, v in zip(tuvs, tuvs, tuvs):
        if t:
            ans.append('1' if uf.same(u, v) else '0')
        else:
            uf.union(u, v)

    print('\n'.join(ans))


if __name__ == "__main__":
    main()

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

int main(){
    string s; cin >> s;
    bool app[26];
    rep(i,26){
        app[i] = false;
    }
    for(int i = 0; s[i] != '\0'; i++){
        app[s[i] - 'a'] = true;
    }
    rep(i,26){
        if(!app[i]){
            cout << (char)(i+'a');
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

bool isPrime[100001];

int main(){
  ll m,a,b;
  vector<ll> primes;
  memset(isPrime,true,sizeof(isPrime));
  isPrime[0] = false;
  isPrime[1] = false;

  for(int i=2;i*i<=100000;i++){
    if(!isPrime[i]) continue;
    for(int j=i*i;j<=100000;j+=i){
      isPrime[j] = false;
    }
  }

  for(int i=2;i<=100000;i++){
    if(isPrime[i]) primes.push_back(i);
  }

  while(~scanf("%ld %ld %ld",&m,&a,&b)){
    if(m==0 && a==0 && b==0) break;

    ll opt_area = 0;
    ll opt_p = 0;
    ll opt_q = 0;
    for(int i=0;i<primes.size();i++){
      if(primes[i] > m) break;
      for(int j=i;j<primes.size();j++){
	if(primes[i] * primes[j] > m) break;

	ll p = primes[i];
	ll q = primes[j];
	//a/b <= p/q <= 1.0
	//q*a/b <= q*p/q
	//-> b*q*a/b <= b*q*p/q
	//-> q*a <= b*p
	// p/q <= 1
	//-> q*p/q <= q
	//-> p <= q
	if(a*q <= b*p && p <= q){
	  if(opt_area < p*q){
	    opt_area = p*q;
	    opt_p = p;
	    opt_q = q;
	  }
	}
      }
    }
    printf("%ld %ld\n",opt_p,opt_q);
  }
}

Measured memory_bytes: 1432
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i)

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

int main() {
  // ios_base::sync_with_stdio(0);

  LL A, B, C, K;
  scanf("%lld%lld%lld%lld", &A, &B, &C, &K);
  printf("%lld\n", K % 2 == 0 ? A - B : B - A);

}


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

#ifdef LOCAL
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define dbgv(x) cerr << #x << " = " << x << endl
#define dbga(arr, len) {cerr << #arr << " = "; for (int _ = 0; _ < len; _++)\
cerr << arr[_] << " "; cerr << endl;}
#define dbgi(it) {cerr << #it << " = "; for (const auto& _ : it)\
cerr << _ << " "; cerr << endl;}
#else
#define dbg(...) (void)0
#define dbgv(x) (void)0
#define dbga(arr, len) (void)0
#define dbgi(it) (void)0
#endif

using ll = long long;
using dbl = long double;
using pii = pair<int, int>;

void solve() {
    int m1, d1, m2, d2;
    scanf("%d%d%d%d", &m1, &d1, &m2, &d2);
    printf("%d\n", m1 == m2 ? 0 : 1);
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    solve();

    dbg("\n\ntime = %.3lf\n", (double)clock() / CLOCKS_PER_SEC);
}


Measured memory_bytes: 256
n,c,k=map(int,input().split())
t=[]
for i in range(n):
    t.append(int(input()))
t.sort()

bus=0
wait_p=0
first_t=-1

for i in range(n):
    ti=t[i]
    if(first_t==-1):
        first_t=ti

    wait_p+=1

    if(ti > first_t+k):
        bus+=1
        first_t=ti
        wait_p=1

    if(wait_p >= c):
        bus+=1
        first_t=-1
        wait_p=0


if(first_t!=-1 or wait_p > 0):
    bus+=1

print(bus)


Measured memory_bytes: 7384
#include <cstdio>
#include <iterator>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <climits>
#include <string>
#include <set>
#include <numeric>
#include <bitset>
#include <cmath>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <numeric>
#include <vector>
#include <cassert>
#include <ctime>

using namespace std;
 
#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
 
using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;
using pii=pair<int, int>;
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto& p: c) os << p << " ";
	return os<<']';
}
 
void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}
 
 
template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}
 
 
constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;
constexpr int maxn=201;

int N, M;
int R, RR[maxn];

ll graph[maxn][maxn];

void solve() {
	while(cin>>N>>M>>R) {
		rep(i, R) cin>>RR[i],RR[i]--;
		rep(i, N) rep(j, N) 
			graph[i][j] = (i == j)? 0: (1ll<<40);
		rep(i, M) {
			int x, y;
			ll r;
			cin>>x>>y>>r;
			x--;
			y--;
			graph[x][y] = min(graph[x][y], r);
			graph[y][x] = min(graph[y][x], r);
		}
		rep(k, N) rep(i, N) rep(j, N) 
			graph[i][j] = min(graph[i][j], graph[i][k]+graph[k][j]);
		
		sort(RR, RR+R);

		ll minlen = 1ll<<40;
		do {
			ll zon = 0;
			rep(i, R-1) zon += graph[RR[i]][RR[i+1]];
			minlen = min(zon, minlen);
		}while(next_permutation(RR, RR+R));

		cout << minlen << endl;
	}
}

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

			


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

int main(){
  int n,m;
  int cardt[100],cardh[100];
  int t_sum,h_sum;
  int st,sh;
  int mins;
  while(cin>>n>>m,n|m){
    t_sum=h_sum=0;
    mins=201;
    for(int i=0;i<n;i++){
      cin>>cardt[i];
      t_sum+=cardt[i];
    }
    for(int i=0;i<m;i++){
      cin>>cardh[i];
      h_sum+=cardh[i];
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if(t_sum-cardt[i]+cardh[j]==h_sum-cardh[j]+cardt[i]){
	  if(cardt[i]+cardh[j]<mins){
	    mins=cardt[i]+cardh[j];
	    st=cardt[i];
	    sh=cardh[j];	 
	  }
	}
      }
    }
    if(mins==201)cout<<"-1"<<endl;
    else cout<<st<<" "<<sh<<endl;
  }
}
	

Measured memory_bytes: 1164
///-----Bismillahir Rahmanir Rahim-----///

#include<bits/stdc++.h>
using namespace std;

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///------------Sorting STL----------///
struct func
{
    //this is a sample overloading function for sorting stl
    bool operator()(pii const &a, pii const &b)
    {
        if(a.F==b.F)
            return (a.S<b.S);
        return (a.F<b.F);
    }
};

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        int n,ans=inf;
        cin>>n;
        int a[n+5];
        for(int i=0; i<n; i++)
        {
            cin>>a[i];
        }
        for(int i=-100; i<=100; i++)
        {
            int cost=0;
            for(int j=0; j<n; j++)
            {
                cost+=((i-a[j])*(i-a[j]));
            }
            ans=min(ans,cost);
        }
        cout<<ans<<endl;

    }
    return 0;
}


Measured memory_bytes: 3628
#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>;

vector<ll> enumDivisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i*i <= n; ++i) {
    if (n%i != 0) continue;
    res.push_back(i);
    if (i*i != n) res.push_back(n/i);
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  int ans = 0;
  for (ll x : enumDivisor(n)) {
    if (x == 1) continue;
    ll tmp = n;
    while (tmp%x == 0) tmp /= x;
    tmp %= x;
    if (tmp == 1) ++ans;
  }
  ans += enumDivisor(n-1).size() - 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int cnt = 0;
	int n = s.size();
	rep(i,n){
		if(s[i] == s[i+1]){
			if(s[i] == '0') s[i+1] = '1';
			else s[i+1] = '0';
			++cnt;
		}
	}
	cout << cnt << '\n';
	return 0;	
}


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	if (n==2)
	{
		int a,b;
		cin>>a>>b;
		cout<<"2\n";
		if (abs(a)<=abs(b))
		{
			cout<<"2 1\n";
			a+=b;
		}
		else
		{
			cout<<"1 2\n";
			b+=a;
		}
		if (a<0)
		{
			cout<<"2 1\n";
		}
		else
		{
			cout<<"1 2\n";
		}
		return 0;
	}
	int a,ma=0,mi=0,ima=-1,imi=-1;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		if (a>ma)
		{
			ma=a;
			ima=i+1;
		}
		else if (a<mi)
		{
			mi=a;
			imi=i+1;
		}
	}
	if (ma==0&&mi==0)
	{
		cout<<"0\n";
		return 0;
	}
	if (abs(ma)>=abs(mi))
	{
		cout<<2*n-2<<endl;
		for (int i = 1; i <= n; ++i)
		{
			if (i==ima)
			{
				continue;
			}
			cout<<ima<<" "<<i<<endl;
		}
		for (int i = 1; i < n; ++i)
		{
			cout<<i<<" "<<i+1<<endl;
		}
	}
	else
	{
		cout<<2*n-2<<endl;
		for (int i = 1; i <= n; ++i)
		{
			if (i==imi)
			{
				continue;
			}
			cout<<imi<<" "<<i<<endl;
		}
		for (int i = n; i > 1; --i)
		{
			cout<<i<<" "<<i-1<<endl;
		}
	}
	return 0;
}


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

typedef long long ll;
const int INF = 1e9;

const int S = 3e5;

map<ll,ll,greater<ll>> m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	vector<ll> nums(n);
	for (ll &it: nums){
		cin>>it;
	}
	ll ans = 0;
	sort(nums.begin(), nums.end(), greater<ll>());
	m[nums[0]] = 1;
	auto it = m.begin();
	for (int i = 1; i < n; i++){
		if ((*it).second == 0){
			it++;
		}
		ans += (*it).first;
		if (nums[i] == (*it).first){
			(*it).second++;
		}else{
			m[nums[i]]+=2;
			(*it).second--;
		}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 17180
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b,d,r;
  double aa,bb,f;
  cin>>a>>b;
  d=a/b;
  r=a-b*(a/b);
  aa=a,bb=b;
  f=(double)(aa/bb);
  printf("%d %d %f\n",d,r,f);
}

Measured memory_bytes: 1184
import java.io.*;
import java.util.*;

class Main{
		
		public static void main(String args[]) throws IOException{
			ArrayList<Integer> inp = new ArrayList<Integer>();
			ArrayList<Integer> out = new ArrayList<Integer>();
			Scanner scan = new Scanner(System.in);
			while(scan.hasNext()){
				String str1 = scan.next();
				inp.add(Integer.valueOf(str1).intValue());
			}
			
			for(int i=0;i<inp.size();i++){
				if(inp.get(i) != 0) out.add(inp.get(i));
				else{
					System.out.println(out.get(out.size()-1));
					out.remove(out.size()-1);
					}
			}
	}
}

Measured memory_bytes: 12000
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

const int N = 505, mod = 1e9 + 7;

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

int fexp(int a, int b)
{
	int x = 1;
	for(; b; b >>= 1, a = 1LL * a * a % mod)
		if(b & 1) x = 1LL * x * a % mod;
	return x % mod;
}

int n, m, k, ans = 1, te = 1, h[N], fr[N * 2], nxt[N * 2], to[N * 2], fac[N], ifac[N], inv[N];
int dfn[N], low[N], ind, cnt, bcc[N], V[N], E[N];
vector<int> stkV;
vector<pair<int, int>> stkE;

void init()
{
	fac[0] = fac[1] = inv[1] = ifac[0] = ifac[1] = 1;
	for(int i = 2; i <= 500; ++i)
	{
		fac[i] = 1LL * fac[i - 1] * i % mod;
		inv[i] = 1LL * inv[mod % i] * (mod - mod / i) % mod;
		ifac[i] = 1LL * ifac[i - 1] * inv[i] % mod;
	}
}

void link(int a, int b)
{
	nxt[++te] = h[a];
	h[a] = te;
	fr[te] = a;
	to[te] = b;
}

void dfs(int u, int fa)
{
	dfn[u] = low[u] = ++ind;
	stkV.push_back(u);
	for(int e = h[u], v; e; e = nxt[e])
	{
		v = to[e];
		if(v == fa || dfn[v] > dfn[u]) continue;
		stkE.emplace_back(u, v);
		if(!dfn[v])
		{
			dfs(v, u);
			if(low[v] >= dfn[u])
			{
				++cnt;
				for(;!stkE.empty();) {
					auto p = stkE.back(); stkE.pop_back();
					++E[cnt];
					if(p.first == u && p.second == v)
						break;
				}
				for(;!stkV.empty();) {
					int p = stkV.back(); stkV.pop_back();
					bcc[p] = cnt;
					++V[cnt];
					if(p == v) break;
				}
				++V[cnt];
			}
			low[u] = min(low[u], low[v]);
		}
		else
			low[u] = min(low[u], dfn[v]);
	}
}

int main()
{
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 1, a, b; i <= m; ++i)
	{
		scanf("%d %d", &a, &b);
		link(a, b); link(b, a);
	}
	init();
	for(int i = 1; i <= n; ++i)
		if(!dfn[i])
			dfs(i, 0);
	for(int i = 1; i <= cnt; ++i)
		if(V[i] == E[i])
		{
			int tmp = 0;
			for(int j = 0; j < V[i]; ++j)
				tmp = (tmp + fexp(k, gcd(j, V[i]))) % mod;
			tmp = 1LL * tmp * inv[V[i]] % mod;
			ans = 1LL * ans * tmp % mod;
		}
		else
		{
			// x1 + x2 +...+ xk = E
			int tmp = 1LL * fac[E[i] + k - 1] * ifac[E[i]] % mod * ifac[k - 1] % mod;
			ans = 1LL * ans * tmp % mod;
		}
	printf("%d", ans);
}

Measured memory_bytes: 256
s=input()
t=input()
ls=len(s)
lt=len(t)
dp=[[0 for i in range(ls)] for i in range(lt)]
a=0
for i in range(ls):
    if t[0]==s[i]:
        a=1
    dp[0][i]=a
a=0
for i in range(lt):
    if s[0]==t[i]:
        a=1
    dp[i][0]=a
for i in range(1,lt):
    for j in range(1,ls):
        if s[j]==t[i]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
ans=[]
x=ls-1
y=lt-1
while x>0 or y>0:
    if x==0:
        y-=1
        if dp[y][0]!=dp[y+1][0]:
            ans.append(t[y+1])
    elif y==0:
        x-=1
        if dp[0][x]!=dp[0][x+1]:
            ans.append(s[x+1])
    elif dp[y][x]==dp[y-1][x]:
        y-=1
    elif dp[y][x]==dp[y][x-1]:
        x-=1
    else:
        x-=1
        y-=1
        ans.append(s[x+1])
if dp[y][x]==1:
    ans.append(s[0])
print(''.join(ans[::-1]))


Measured memory_bytes: 119388