akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;


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

    int N, K, result = 0;
    cin >> N >> K;

    int h[100000] = {};

    for0(i, N){
        cin >> h[i];
        if (h[i] >= K) ++result;
    }

    cout << result;

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;


int main() {
 
  int64_t N,K;
  cin>>N>>K;
  vector<int64_t> A(N);
  vector<string> ans(N);
  for(int i=0; i<N; i++){cin>>A[i];}
  for(int i=0; i<N-K; i++){
    if(A[i]<A[i+K])cout<<"Yes"<<endl;
      else cout<<"No"<<endl;}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
}
 

Measured memory_bytes: 11176
n=int(input())
a=[int(i) for i in input().split()]

l=[0]
def ruiseki(a):
    for i in range(n):
        l.append(l[i]+a[i])
    del l[0]

ans=100000000000000
ruiseki(a)
x=0
y=0

for i in range(n-1):
    x=l[i]
    y=l[-1]-x
    ans=min(ans,abs(x-y))
    

print(ans)







Measured memory_bytes: 24688
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int H,W;
char s[50][50];
int score[50][50] = {0};

void bfs(int h,int w,int x,int y,int ss)
{
    score[y][x] = ss+1;

    if (x+1 < w && score[y][x+1] > score[y][x] + 1 && s[y][x+1] != '#')
    {
        bfs(h,w,x+1,y,score[y][x]);
    }

    if (x-1 >= 0 && score[y][x-1] > score[y][x] + 1 && s[y][x-1] != '#')
    {
        bfs(h,w,x-1,y,score[y][x]);
    }

    if (y+1 < h && score[y+1][x] > score[y][x] + 1 && s[y+1][x] != '#')
    {
        bfs(h,w,x,y+1,score[y][x]);
    }

    if (y-1 >= 0 && score[y-1][x] > score[y][x] + 1 && s[y-1][x] != '#')
    {
        bfs(h,w,x,y-1,score[y][x]);
    }
}


int main()
{
    cin >> H >> W;

    for(int i = 0; i < H ; i++)
    {
        for(int j = 0; j < W; j++)
        {
            cin >> s[i][j];
        }
    }

    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            score[i][j] = INF;
        }
    }

    bfs(H,W,0,0,0);

    if (score[H-1][W-1] > H * W)
    {
        cout << "-1" << endl;
    }else
    {
        int cnt = 0;
        for(int i = 0; i < H; i++)
        {
            for(int j = 0; j < W; j++)
            {
                if (s[i][j] == '#')
                {
                    cnt++;
                }
            }
        }
        cout << (H*W-cnt) - score[H-1][W-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
	int counter[101];
	for(auto& i : counter)
		i = 0;

	{
		size_t input;
		while(cin >> input)
			counter[input]++;
	}

	int max = 0;
	for(auto& i : counter)
		if(max < i)
			max = i;

	for(int i = 1; i < 101; i++)
		if(counter[i] == max)
			cout << i << endl;

	return 0;
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
N, L = map(int, input().split())
list = []
for _ in range(N) :
  list.append(str(input()))

list.sort()

ans = ""
for i in range(N) :
  ans += list[i]

print (ans)
  

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll mod=1e9+7;
const ll N = 2e5+10;





void solve(){
    
    ll n=0,k=0,m=0,a=0;
    cin>>n;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            for(ll k=1;k<=n;k++){
                ll an=__gcd(i,j);
                ll gg=__gcd(an,k);
                m+=gg;
            }
        }

    }
    cout<<m<<"\n";


        
}
        
        

int main(){
        
    
        ios_base::sync_with_stdio(0);
        cin.tie(0);cout.tie(0);
        ll T=1;
        //cin>>T;
        for (ll i = 1; i <=T; i++) {
            //cout<<"Case #"<<i<<": ";
            solve();
        }
            
            
        return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll K,N;
    cin >> K >> N;
    vector<ll> v(N);
    vector<ll> v2(N);
    ll ans = 0;
    rep(i, N) cin >> v[i];
    for (int i = 0; i < N; i++){
        v2[i] = abs(v[i] - v[i + 1]);
    }
    v2[N-1] = K - v[N-1] + v[0];
    sort(v2.begin(), v2.end());
    for(int i = 0; i < N-1; i++) {
        ans += v2[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;

class modInt{
    ll value;
    static const ll mod = 998244353;

public:
    modInt(ll x=0): value{x % mod}{}

    inline modInt& operator+=(modInt x){
        value = (value + x.value) % mod;
        return *this;
    }

    inline modInt& operator-=(modInt x){
        value = (value + mod - x.value) % mod;
        return *this;
    }

    inline modInt& operator*=(modInt x){
        value = (value * x.value) % mod;
        return *this;
    }


    inline modInt operator/=(modInt x){
        *this *= x.inv();
        return *this;
    }

    inline modInt pow(ll n){
        modInt res = modInt(1LL);
        modInt x{value};
        while(n > 0){
            if(n & 1)   res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }

    inline modInt inv(){
        modInt res = pow(mod-2);
        return res;
    }

    inline ll get(){
        return value;
    }
};

modInt operator+(modInt x, modInt y){
    return x += y;
}

modInt operator-(modInt x, modInt y){
    return x -= y;
}

modInt operator*(modInt x, modInt y){
    return x *= y;
}

modInt operator/(modInt x, modInt y){
    return x /= y;
}

ostream& operator<<(ostream& os, modInt x){
    return os << x.get();
}


class modIntCombinations{
    vector<modInt> factArray;

    void make_fact(ll x){
        for(auto i = factArray.size(); i <= x+1; i++){
            modInt y = factArray[i-1] * i;
            factArray.push_back(y);
        }
    }

public:
    modIntCombinations(){
        factArray.emplace_back(1);
    }

    modInt fact(ll x){
        if(factArray.size() < x+1){
            make_fact(x);
        }
        return factArray[x];
    }

    modInt comb(ll n, ll k){
        if(n < k){
            return modInt{0};
        }
        else{
            return fact(n) / fact(k) / fact(n - k);
        }
    }

    modInt perm(ll n, ll k){
        if(n < k){
            return modInt{0};
        }
        else{
            return fact(n) / fact(k);
        }
    }
};


int main(){
    int n, s;   cin >> n >> s;
    vector<vector<modInt>> dp(n+1, vector<modInt>(s+1, 0));
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= s; j++){
            dp[i+1][j] += dp[i][j] * 2;   // 使わない (使っても使わなくてもok)
            if(j + a[i] <= s){
                dp[i+1][j + a[i]] += dp[i][j];     // 使う
            }
        }
    }
    cout << dp[n][s] << endl;



    return 0;
}


Measured memory_bytes: 74076
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
long long int a[333],b[333],c[333],d[333];

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    if(a+b==c+d)cout<<"Balanced"<<endl;
    else if(a+b>c+d)cout<<"Left"<<endl;
    else cout<<"Right"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;
string s;
int a[1222333];

int main() {
	cin >> n;
	cin >> s;
	if (n == 1) {
		cout << s << "\n";
		return 0;
	}
	int f = 0;
	for (int i = 0; i+1 < n; i++) {
		a[i] = abs(s[i]-s[i+1]);
		if (a[i] == 1) f = 1;
	}
	if (f) {
		for (int i = 0; i < n-1; i++) {
			a[i] %= 2;
		}
	} else {
		for (int i = 0; i < n-1; i++) {
			a[i] /= 2;
		}
	}
	int x = 0;
	for (int i = 0; i < n-1; i++) {
		if (a[i] == 0) continue;
		if ((i|(n-2)) == n-2) x = 1-x;
	}
	if (!f) x *= 2;
	cout << x << "\n";
}


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

using namespace std;

const int MaxN = 100005;
const int Mod = 1000000007;

int n, D;
string s;
long long dp[MaxN], tmp[MaxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    cin >> D;
    n = s.size();
    for (int i = s[0] - '0' - 1; i >= 0; i--)
    {
        dp[i % D]++;
    }
    int Sums = (s[0] - '0') % D;
    for (int i = 1; i < n; i++)
    {
        int x = s[i] - '0';
        for (int k = 0; k < D; k++)
        {
            tmp[k] = tmp[k] + dp[k];
            tmp[k + 10] = tmp[k + 10] - dp[k] + Mod;
        }
        tmp[Sums]++;
        tmp[Sums + x]--;
        Sums = (Sums + x) % D;
        dp[0] = tmp[0];
        tmp[0] = 0;
        for (int k = 1; k < D + 10; k++)
        {
            dp[k] = (tmp[k] + dp[k - 1]) % Mod;
            tmp[k] = 0;
        }
        for (int k = D; k < D + 10; k++)
        {
            dp[k % D] = (dp[k % D] + dp[k]) % Mod;
        }
    }
    long long ans = (dp[0] + (Sums % D == 0) - 1 + Mod) % Mod;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	ll N;
	ll res=0;
	string sres="No";
	string s,t;
	cin>>s;
	cin>>t;
	if(1<=SIZE(s)&&SIZE(s)<=10) {
		if (s==t.erase(SIZE(t)-1)) sres="Yes";
	}

	cout << sres << "\n";
	return;
}

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


Measured memory_bytes: 3640
import itertools
S = input()
op = list(itertools.product('+ ', repeat=len(S)-1))
calcs = []
for i in range(len(op)):
  calc = ""
  for j in range(len(S)-1):
    calc += S[j] + op[i][j]
  calc += S[-1]
  calcs.append(calc)

for i in range(len(calcs)):
  calcs[i] = eval(calcs[i].replace(" ",""))

print(sum(calcs))

Measured memory_bytes: 3188
a = input()
b = input()

l = []
for i in range(len(a) - len(b) + 1):
    cnt = 0
    for j in range(len(b)):
        if b[j] == a[i + j]:
            cnt += 1
    l.append(cnt)

#print(l)
print(len(b) - max(l))

Measured memory_bytes: 9028
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char S[101];
    size_t len;

    gets(S);

    len = strlen(S);

    for (size_t i = 0; i < len; i++) {
        S[i] = 'x';
    }

    puts(S);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int x[100010],d[100010];
struct srt{int p,d,i;}w[100010];
bool operator<(srt a,srt b){
	if(a.p^b.p)return a.p<b.p;
	return a.d>b.d;
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),L=gi(),T=gi();
	for(int i=1;i<=n;++i)x[i]=gi(),d[i]=gi(),w[i]={((x[i]+(d[i]==1?T:-T))%L+L)%L,d[i],i};
	int w1=w[1].p;
	std::sort(w+1,w+n+1);
	ll qwq=0;
	for(int i=1;i<=n;++i)
		if(d[i]!=d[1])
			if(d[1]==1)qwq+=(0ll+2*T-x[i]+x[1]+L)/L;
			else qwq+=(0ll+2*T-x[1]+x[i])/L;
	if(d[1]==2)qwq=-qwq;
	qwq=(qwq%n+n)%n+1;
	for(int i=1;i<=n;++i)if(w[i].p==w1&&w[i].d==d[1]){qwq=(i-qwq+n)%n+1;break;}
	for(int i=qwq;i<=n;++i)printf("%d\n",w[i].p);
	for(int i=1;i<qwq;++i)printf("%d\n",w[i].p);
	return 0;
}


Measured memory_bytes: 3200
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] pc = new int[N + 1];
        long[] P = new long[M];
        long[][] Y = new long[M][3];
        Arrays.fill(pc, 0);
        for (int i = 0; i < M; i++) {
            P[i] = sc.nextLong();
            Y[i][0] = sc.nextLong();
            Y[i][1] = i;
            Y[i][2] = P[i];
        }
        Arrays.sort(Y, (a, b) -> Long.compare(a[0], b[0]));
        for (int i = 0; i < M; i++) {
            pc[(int) Y[i][2]]++;
            Y[i][0] = pc[(int) Y[i][2]];
        }
        Arrays.sort(Y, (a, b) -> Long.compare(a[1], b[1]));
        for (int i = 0; i < M; i++) {
            if (String.valueOf(P[i]).length() == 2) {
                System.out.print("0000");
            } else if (String.valueOf(P[i]).length() == 3) {
                System.out.print("000");
            } else if (String.valueOf(P[i]).length() == 4) {
                System.out.print("00");
            } else if (String.valueOf(P[i]).length() == 5) {
                System.out.print("0");
            } else if (String.valueOf(P[i]).length() == 1) {
                System.out.print("00000");
            }
            System.out.println(P[i] * 1000000 + Y[i][0]);
        }
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    string X;
    cin >> X;
    X = 'T' + X;
    ll ans = 0;
    ll t_cn = 0;
    ll s_cn = 0;
    for(ll i = X.length()-1; i >= 0; i--){
        if(X[i] == 'T') t_cn++;
        if(X[i] == 'S') s_cn++;
        if(X[i] == 'S' && X[i-1] == 'T'){
            ans += 2 * min(t_cn, s_cn);
            t_cn -= min(t_cn, s_cn);
            s_cn = 0;
        }
        //cout << t_cn << " " << s_cn << endl;
    }

    cout << X.length() - ans - 1 << endl;
    
}

Measured memory_bytes: 772
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n - 1).map { sc.next().toInt() }
    println(problem163c(n, a))
}

fun problem163c(n: Int, a: List<Int>): String {
    val map = mutableMapOf<Int, Int>()
    for (i in 0 until n - 1) {
        val ai = a[i]
        if (map.containsKey(ai)) {
            map[ai] = map[ai]!! + 1
        } else {
            map[ai] = 1
        }
    }
    val list = mutableListOf<Int>()
    for (i in 1..n) {
        if (map.containsKey(i)) {
            list.add(map[i]!!)
        } else {
            list.add(0)
        }
    }
    return list.joinToString("\n")
}

Measured memory_bytes: 80096
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=1e9+7;
const ll ms=2e5+5;
const ll inf=1e17;

vector<pair<ll,ll>> vv;

map<ll,ll> mm;
map<ll,ll> m2;


int main()
{
    idfc;

    ll n;
    cin>>n;
    ll i;
    ll a,b;

    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        vv.pb({a,b});
    }
    sort(vv.begin(),vv.end());

    mm[vv[0].second]=vv[0].first+vv[0].second;
    m2[vv[0].second]=vv[0].first-vv[0].second;

    ll ans=0;
    ll x;
    for(i=1;i<n;i++)
    {
        a=vv[i].first;
        b=vv[i].second;
        auto it=mm.upper_bound(b);
        if(it!=mm.begin())
        {
         it--;
         x=a+b-((*it).second);
         ans=max(ans,x);
        }
        auto ii=m2.lower_bound(b);
        if(ii!=m2.end())
        {
            x=(a-b)-((*ii).second);
            ans=max(ans,x);
        }

        while(!mm.empty()&&mm.lower_bound(b)!=mm.end())
        {
            x=(*mm.lower_bound(b)).second;
            if(x>=(a+b))
            {
                mm.erase((*mm.lower_bound(b)).first);
            }
            else break;
        }
        if(mm.empty())
        {
            mm[b]=a+b;
        }
        else{
            it=mm.upper_bound(b);
            if(it!=mm.begin())
            {
                it--;
                if((*it).second>(a+b))
                {
                    mm[b]=a+b;
                }
            }
            else{
                mm[b]=a+b;
            }
        }

        while(!m2.empty()&&m2.upper_bound(b)!=m2.begin())
        {
            auto ip= m2.upper_bound(b);
            ip--;
            x=(*ip).second;
            if(x>=(a-b))
            {
                m2.erase((*ip).first);
            }
            else break;
        }

        if(m2.empty())
        {
            m2[b]=a-b;
        }
        else{
            it=m2.lower_bound(b);
            if(it!=m2.end())
            {
                if((*it).second>(a-b))
                {
                    m2[b]=a-b;
                }
            }
            else m2[b]=a-b;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 7416
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    string s;
    cin >> s;

    int l = s.size();
    int g = 0;

    rep(i, l) {
        if(s[i]=='g') g++;
    }

    cout << g-(l+1)/2 << endl;
    

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb  push_back
#define mod 1000000007
#define INF 1e18
typedef  long long ll;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s,t;
	cin>>s>>t;
	int ans=INT_MAX;
	for (int i = 0; i <= s.length()-t.length(); ++i)
	{
		int curr=0;
		for (int j = i,k=0; k <t.length() ; ++j,++k)
		{
			if(s[j]!=t[k])
				curr++;
		}
		ans=min(curr,ans);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    for(int i=0; i<n; i++) {
        for(int j=0; j<d; j++) {
            cin >> x[i][j];
        }
    }
    
    int ans = 0;
    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
            double dist = 0;
            for(int k=0; k<d; k++) {
                dist += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            dist = sqrt(dist);
            if(ceil(dist) == floor(dist)) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


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

const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int main() {
  int n;
  cin >> n;
  cout << n * (n+1) / 2 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
					using namespace std;
					#define pll pair<ll,ll>
					typedef long long ll;
					#define mod 51123987
					#define fi first
					#define se second
					#define mp make_pair
					#define pb push_back
					#define INF 1e15
					
					
					int main()
					{
						ll a,b,c;
						cin>>a>>b>>c;
						cout<<(a/(b+c))*b+min(b,a%(b+c));
						
					}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		char[] chars = s.toCharArray();
		
		// 計算
		int result = 0;
		int cnt  = 0;
		for(int i = 0; i < s.length(); i++){
		    char c = s.charAt(i);
		    if(c == 'A' || c == 'T' || c == 'C' || c == 'G'){
		        cnt++;
		        continue;
		    }
		    result = max(result, cnt);
		    cnt = 0;
		}
		result = max(result, cnt);

		// 出力
		System.out.println(result);
        
	}
}


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



int main(){
  int a;
  cin >>a;
  for(int i=9;i>0;i--){
    if(a%i==0&&a/i<10){
      cout<<"Yes"<<endl;
      break;
    }
    if(i==1){
      cout<<"No"<<endl;
    }
  }
}


Measured memory_bytes: 256
N = int(input())
C, S, F = [], [], []
for _ in range(N-1):
    c, s, f = tuple(map(int, input().split()))
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(N):
    total_time = 0
    for j in range(i, N-1):
        if total_time < S[j]:
            total_time = S[j]
        elif total_time % F[j] == 0:
            pass
        else:
            total_time = total_time + (F[j] - total_time % F[j])
        total_time += C[j]
    print(total_time)


Measured memory_bytes: 3188
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<ctime>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<tuple>
#include<cassert>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<iomanip>
#include<climits>
#include<typeinfo>
#include<utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
double pi = 3.141592653589793238;
using ll = long long;
using namespace std;

ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpcombination[10000][10000];

ll modi = 1000000007;
ll combination(ll n, ll r) {
	if (n == r) { return dpcombination[n][n] = 1; }
	else if (r == 0) { return dpcombination[n][0] = 1; }
	else if (r == 1) { return dpcombination[n][1] = n; }
	else if (dpcombination[n][r]) { return dpcombination[n][r]; }
	else { return dpcombination[n][r] = combination(n - 1, r - 1) % modi + combination(n - 1, r) % modi; }
}

void clockman(int time1) {

	cout << 1.0*(clock() - time1) / CLOCKS_PER_SEC << endl;
	return;
}
//cout << fixed << setprecision(10)



int main() {
	
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int ti1 = 60 * h1 + m1;
	int ti2 = 60 * h2 + m2;
	cout<<ti2 - ti1 - k << endl;




	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(){
	string s;
	int hug,tmp;
	cin >> s ;
	hug = 0;
	tmp = s.size();
	for(int i = 0;i< tmp / 2;i++)
	{
		if(s[i] != s[tmp -1 - i])
		{
			hug++;
		}
	}
	cout << hug << endl;
}
	

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int K, X;
    cin >> K >> X;

    for(int i = X - (K - 1); i <= X + (K - 1); ++i) {
        printf("%lld%c", i, (i == (X + K - 1)) ? '\n' : ' ');
    }

    return 0;
}

Measured memory_bytes: 384
parseInt(x) = parse(Int, x)

function main()
  n = parseInt(readline())
  k = parseInt(readline())
  x = map(parseInt, split(readline()))
  sum = 0
  for i in 1:n
    sum += 2*min(x[i], k-x[i])
  end
  print(sum)
end

main()

Measured memory_bytes: 111684
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> li = new ArrayList<Integer>();
        for(int i = 0; i < n; i++){
            li.add(sc.nextInt());
        }
        int cnt = 0;
        int[] ans = new int[200001];
        for(int i = 0; i < n; i++){
            int now = n-i;
            int tmp = 0;
            for(int j = 2; j <= n; j++){
                if(j * now > n){
                    break;
                }else if(ans[j*now] == 1){
                    tmp++;
                }
            }
            if((li.get(now-1)+tmp)%2 == 1){
                cnt++;
                ans[now]++;
            }
        }
        System.out.println(cnt);
        for(int i = 1; i <= n; i++){
            if(ans[i] == 1){
                System.out.print(i+" ");
            }
        }
    }
}

Measured memory_bytes: 66364
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  ll ans = 0;
  while(n != 4 && n != 2 && n != 1){
    if(n % 2 == 0) n /= 2;
    else n = n*3+1;
    ans++;
  }
  cout << ans+4 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int n,k;
long long x[114514];
long long ans=400000000;

int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>x[i];

    for(int i=0;i<n-k+1;i++){
        long long value=x[i+k-1]-x[i];
        value += min(abs(x[i]),abs(x[i+k-1]));
        ans=min(value,ans);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int gcd(int a, int b){
  if (b>a) swap(a,b);
  if (b==0) return a;
  return gcd(b, a%b);
}

int lcm(int a, int b){
  return (a/gcd(a,b))*b;  // overflowしにくいように最初に割り算をする。
}

int solve(){
  int a,b,c,d;cin>>a>>b>>c>>d;

  int res = b-a+1;

  int e = lcm(c, d);
  dump(e);
  int p = b/c - (a+c-1)/c + 1;
  int q = b/d - (a+d-1)/d + 1;
  int r = b/e - (a+e-1)/e + 1;
  dump(p, q, r);

  res -= (p+q-r);
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include<cstdio>
int main()
{
	long long a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	long long ans=a*b,num=c*d;
	if(ans>=num)
	printf("%lld\n",ans);
	else
	printf("%lld\n",num);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int num=0;

void merge(int A[], int n, int left, int mid, int right){
    int n1=mid-left;
    int n2=right-mid;
    int i, j, k;
    int L[250001], R[250001];
    
    for(i=0; i<n1; i++) L[i]=A[left+i];
    for(i=0; i<n2; i++) R[i]=A[mid+i];
    
    L[n1]=1000000000;
    R[n2]=1000000000;
    
    i=j=0;
    for(k=left; k<right; k++){
        num++;
        if(L[i]<=R[j]){
            A[k]=L[i++];
        }else{
            A[k]=R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}


int main() {

    int A[500000];
    int n, i;
    
    scanf("%d\n", &n);
    for(i=0; i<n; i++) scanf("%d\n", &A[i]);
    
    mergeSort(A, n, 0, n);
    
    for(i=0; i<n; i++){
        if(i) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    
    printf("%d\n", num);
    
    return 0;
}



Measured memory_bytes: 5600
import java.util.Scanner;

// Main
class Main {
	static final int INIT = 8;
	static int[] grow(int[] s) {
		int[] d = new int[s.length * 2];
		System.arraycopy(s, 0, d, 0, s.length);
		return d;
	}

	static class Stack {
		private int[] data;
		public Stack() {
			data = new int[INIT];
			// data[0] を項目数にする
		}
		public boolean isEmpty() {
			return data[0] == 0;
		}
		public void push(int x) {
			int next = data[0] + 1;
			if (next >= data.length) {
				data = grow(data);
			}
			data[next] = x;
			data[0] = next;
		}
		public int getTop() {
			return data[data[0]];
		}
		public void pop() {
			if (!isEmpty()) {
				data[0] -= 1;
			}
		}
	}

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Stack[] s = new Stack[n];
			for (int i = 0; i < n; i++) {
				s[i] = new Stack();
			}
			int q = sc.nextInt();
			for (int i = 0; i < q; i++) {
				int c = sc.nextInt();
				int t = sc.nextInt();
				switch (c) {
				case 0:
					int x = sc.nextInt();
					s[t].push(x);
					break;
				case 1:
					if (!s[t].isEmpty()) {
						System.out.println(Integer.toString(s[t].getTop()));
					}
					break;
				case 2:
					s[t].pop();
					break;
				}
			}
		}
	}
}



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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<int> nums;
	for (int i = 0; i < n; ++i)
	{
		int buf;
		cin >> buf;
		nums.push_back(buf);
	}
	int ans = 0;
	for (int i = 1; i < n - 1; ++i)
	{
		if (nums[i] > nums[i - 1] && nums[i] < nums[i + 1])
		{
			ans++;
		}
		else if (nums[i] < nums[i - 1] && nums[i] > nums[i + 1])
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
#include <map>
// #include <bits/stdc++.h>


using namespace std;
typedef long long li;


class UnionFind {
    vector<int> parent;
    vector<int> rank;

public:
    UnionFind(int n){
        parent = vector<int>(n, -1); // parent[i] = -1 -> i is root.
        rank = vector<int>(n, 0);
    }

    int find(int n){
        vector<int> path;
        while(parent[n]!=-1){
            path.push_back(n);
            n = parent[n];
        }
        for(vector<int>::iterator it = path.begin(); it != path.end(); it++){
            parent[*it] = n;
            rank[*it] = 0;
        }
        return n;
    }

    void unify(int x, int y){
        int rx = find(x), ry = find(y);
        if(rx == ry) return;

        if(rank[rx] < rank[ry]){
            parent[rx] = ry;
        } else {
            parent[ry] = rx;
            if(rank[rx] == rank[ry]) rank[rx]++;
        }
    }

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

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

    li n, k, l;
    cin >> n >> k >> l;

    UnionFind road(n), rail(n);
    for (int i = 0; i < k; ++i) {
        li a, b;
        cin >> a >> b;
        road.unify(a - 1, b - 1);
    }

    for (int i = 0; i < l; ++i) {
        li a, b;
        cin >> a >> b;
        rail.unify(a - 1, b - 1);
    }

    vector<vector<li>> road_clusters(n);
    for (int i = 0; i < n; ++i) {
        road_clusters[road.find(i)].push_back(i);
    }

    vector<li> ans(n);
    for (int _cluster = 0; _cluster < n; ++_cluster) {
        map<li, vector<li>> city_clusters;
        for (const auto &city : road_clusters[_cluster]) {
            city_clusters[rail.find(city)].push_back(city);
        }
        for (const auto &city : road_clusters[_cluster]) {
            ans[city] = city_clusters[rail.find(city)].size();
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i];
        if (i + 1 == n) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 19828
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    vector<int> cnt(N+1);
    for (int i = 1; i < N; i++) {
        if (S[i-1] == 'A' && S[i] == 'C') cnt[i+1] = 1;
        cnt[i+1] += cnt[i];
    }
    for (int i = 0; i < Q; i++) {
        int l, r; cin >> l >> r;
        cout << cnt[r] - cnt[l] << endl;
    }
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <numeric>
#include <random>

void sort2vectors(std::vector<long long int> &av, std::vector<long long int> &bv)
{
        long long int n = av.size();
        std::vector<long long int> p(n), av2(n), bv2(n);
        std::iota(p.begin(), p.end(), 0);
        std::sort(p.begin(), p.end(), [&](long long int a, long long int b) { return av[a] < av[b];});
        for (long long int i = 0; i < n; i++) {
                av2[i] = av[p[i]];
                bv2[i] = bv[p[i]];
        }
        av = av2;
        bv = bv2;
}

int main(){
  long long int n,m,i;
  scanf("%lld",&n);
  scanf("%lld",&m);
  std::vector<long long int> a(n);
  std::vector<long long int> b(n);
  for(i=0;i<n;i++) {
    scanf("%lld",&a[i]);
    scanf("%lld",&b[i]);
  }
  sort2vectors(a,b);
  long long int residue = m;
  long long int ans = 0;
  i = 0;
  while(residue > 0) {
    if(residue > b[i]) {
      ans += a[i] * b[i];
      residue -= b[i];
    } else {
      ans += a[i] * residue;
      residue = 0;
    }
    i++;
  }
  printf("%lld\n",ans);
  return 0;
}


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

class UnionFind {
private:
  vector<int> par;
public:
  UnionFind(int N) {
    par.resize(N);
    for (int i = 0; i < N; i++) par[i] = i;
  }
  int root(int x) { return (x == par[x])? x: (par[x] = root(par[x])); }
  void unite(int x, int y) { par[root(y)] = root(x); }
  bool same(int x, int y) { return (root(x) == root(y)); }
};


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

  ll N; cin >> N;
  vector<ll> G[N];
  for (ll i = 0; i < N - 1; i++) {
    ll a, b; cin >> a >> b; a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  vector<ll> d(N, -1);
  vector<ll> prev(N, -1);
  vector<bool> used(N, 0);
  queue<ll> q;

  q.push(0);
  d[0] = 0;
  used[0] = true;
  while (!q.empty()) {
    ll c = q.front(); q.pop();
    for (auto n: G[c]) {
      if (!used[n]) {
        d[n] = d[c] + 1;
        prev[n] = c;
        used[n] = true;
        q.push(n);
      }
    }
  }

  vector<ll> path(d[N - 1] + 1, 0); // path from 1 to N
  path[d[N - 1]] = N - 1;
  for (ll i = d[N - 1] - 1; i >= 0; i--) {
    path[i] = prev[path[i + 1]];
  }
  ll m1 = path[d[N - 1] / 2], m2 = path[d[N - 1] / 2 + 1];


  UnionFind UF(N);
  for (ll i = 0; i < N; i++) {
    for (auto n: G[i]) {
      if (i == m1 && n == m2) continue;
      if (i == m2 && n == m1) continue;
      UF.unite(i, n);
    }
  }
  ll cnt1 = 0, cntN = 0;
  for (ll i = 0; i < N; i++) {
    if (UF.same(0, i)) cnt1++;
    if (UF.same(N - 1, i)) cntN++;
  }

  if (cnt1 > cntN) {
    cout << "Fennec" << '\n';
  } else {
    cout << "Snuke" << '\n';
  }

  return 0;
}

Measured memory_bytes: 8576
import numpy as np

n = int(input())
a = list(map(int,input().split()))
a = sorted(a)

max_n = a[-1]
del a[-1]

def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]
    
half_n = max_n/2

print(max_n,getNearestValue(a,half_n))

Measured memory_bytes: 23492
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int n;
 cin>>n;
 long long int a[n],s=1;
 for(int i=0;i<n;i++)
 {
     cin>>a[i];
     if(a[i]==0)
     {
         cout<<"0";
         return 0;
     }
 }
 for(int i=0;i<n;i++)
 {  if(a[i]<=(long long int)1e18/s)
     {
         s=s*a[i];
         
     }
     else
     {
         cout<<"-1";
         return 0;
     }
 }  
 cout<<s<<endl;
}  

Measured memory_bytes: 4416
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int D[523][523];
int g[523][523];
int cnt,fx,fy;

void find(int y,int x){
  if(D[y][x]){
    fy=y+1;
    fx=x+1;
    cnt++;
    int p=D[y][x];
    g[fy][fx]=p;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
	D[y+i][x+j]-=p;
      }
    }
  }
}

int main(){
  int H,W;
  cin>>H>>W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>D[i][j];
    }
  }
  for(int i=0;i<W;i++){
    int y=0,x=i;
    for(;x>=0;y++,x--){
      find(y,x);
    }
  }
  for(int i=1;i<H;i++){
    int y=i,x=W-1;
    for(;y<H;y++,x--){
      find(y,x);
    }
  }
  vector<pair<int,int> > ans;
  if(cnt==1){
    ans.emplace_back(fy,fx);
  }else{
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if(g[i][j]){
	  int d=g[i][j]-1;
	  for(int k=-1;k<=1;k++){
	    int ny=i+k;
	    if(ny<0||H<=ny)continue;
	    for(int l=-1;l<=1;l++){
	      int nx=j+l;
	      if(nx<0||W<=nx||k==0&&l==0)continue;
	      d+=g[ny][nx];
	    }
	  }
	  if(d%2){
	    ans.emplace_back(i,j);
	  }
	}
      }
    }
  }
  cout<<ans.back().first<<' '<<ans.back().second<<' '<<ans[0].first<<' '<<ans[0].second<<endl;
}

Measured memory_bytes: 2948
#include<iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(){
  long long a, b, k; cin >> a >> b >> k;
    if ( a >= k ){ cout << a-k << " " << b << endl;}
    else if ( a+b >=k ){ cout << 0 << " " << b-k+a << endl;}
    else { cout << 0 << " " << 0 << endl;}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a == b && b == c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	ll n, m; cin >> n >> m;
	vector<ll> v;
	for(ll i=1;i*i<=m;i++){
		if(m%i==0){
			v.push_back(i);
			v.push_back(m/i);
		}
	}
	sort(v.rbegin(), v.rend());
	for(auto c: v){
		if(c<=m/n){
			cout << c << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct A{
    int va,po;
} a[200020];
bool order(A a,A b){
    return a.va<b.va;
}
int ans[200020];
int main()
{
    int n,i,ii;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&a[i].va);
        a[i].po=i;
    }
    sort(a+1,a+n+1,order);
    for(i=1;i<=n;i++){
        ii=a[i].po;
        if(i<=n/2){
            ans[ii]=a[n/2+1].va;
        }
        else{
            ans[ii]=a[n/2].va;
        }
    }
    for(i=1;i<=n;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 4480
#define _CRT_SECURE_NO_WARNINGS

#define N (1<<6)
#define T (1<<17)
#define MODULO (1000000007)
#define HA1 (2420609)
#define HA2 (19260817)

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <complex>
using namespace std;

namespace MRAND
{
	class MRNDS
	{
	public:
		int ngf;
		unsigned int lgf;
		MRNDS()
		{
			ngf = HA1*HA2;
			lgf = HA1 - HA2*ngf;
		}
		MRNDS(long long rgf)
		{
			lgf = rgf&((1LL << 32) - 1LL);
			ngf = (rgf >> 31);
			ngf += 2LL * lgf;
			ngf *= HA2;
			lgf += HA1;
		}
		MRNDS operator* (const MRNDS &mrs)const
		{
			MRNDS Res;
			Res.ngf += ngf*mrs.lgf;
			Res.ngf -= mrs.ngf*lgf;
			Res.ngf *= HA1;
			Res.lgf *= HA2;
			return Res;
		}
	}curl, curr;
	inline void InitRand(MRNDS &Lmrs, MRNDS &Rmrs)
	{
		curl = Lmrs;
		curr = Rmrs;
		curl = curl*curr;
		curl.ngf += HA2;
	}
	inline int GetRand()
	{
		curl = curl*curr;
		return (curl.lgf*HA1 - curr.ngf*HA2);
	}
}

int n, x, y, z;
int dp[N][T];
long long ppw[N];

long long Solve(const int cur, const int msk)
{
	if (cur == 0)
	{
		return 0LL;
	}
	if (dp[cur][msk] != -1LL)
	{
		return dp[cur][msk];
	}
	long long Res = 0LL;
	for (int i = 1;i <= 10;i++)
	{
		int zz = z - i;
		int yy = y + z - i;
		int xx = x + y + z - i;
		if (zz >= 0 && (msk&(1 << zz)) && (msk&(1 << yy)) && (msk&(1 << xx)))
		{
			Res += ppw[cur - 1];
			if (Res >= (long long)MODULO)
			{
				Res -= (long long)MODULO;
			}
		}
		else
		{
			int nmsk = (msk << i)&((1 << 17) - 1);
			nmsk |= 1;
			Res += Solve(cur - 1, nmsk);
			if (Res >= (long long)MODULO)
			{
				Res -= (long long)MODULO;
			}
		}
	}
	return dp[cur][msk] = Res;
}

int main()
{
	scanf("%d%d%d%d", &n, &x, &y, &z);
	ppw[0] = 1LL;
	for (int i = 1;i <= n + 1;i++)
	{
		ppw[i] = ppw[i - 1] * 10LL;
		ppw[i] %= (long long)MODULO;
	}
	memset(dp, -1, sizeof(dp));
	//throw;
	printf("%lld\n", Solve(n, 1));
	//system("pause");
	return 0;
}


Measured memory_bytes: 33024
package main

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

func main() {
	S, T := ReadString(), ReadString()
	ans := 0
	for i := 0; i < len(S); i++ {
		if S[i] != T[i] {
			ans++
		}
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }

func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4516