akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vii = vector<ii>;
using vvii = vector<vii>;

template<class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class TIn, class TOut = null_type>
using order_tree = tree<TIn, TOut, less<TIn>, rb_tree_tag,
	tree_order_statistics_node_update>;

constexpr ll INF = 1000000010;
constexpr ll LLINF = 1000000000000000010LL;

bool modquery(vi &B, ll l, ll r, ll N) {
	if (r - l >= N) return B.back() > 0;
	l = (l % N + N) % N;
	r = (r % N + N) % N;
	if (l <= r)
		return (B[r] - (l > 0 ? B[l - 1] : 0)) > 0;
	else
		return (B[r] + B[N - 1] - B[l - 1] > 0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string A, B;
	cin >> A >> B;

	if (A == B) {
		cout << 0 << endl;
		return 0;
	}

	ll N = (ll)B.length(), best = INF;
	vi Bp(N, ll(B[0] == '1'));
	for (ll i = 1; i < N; ++i)
		Bp[i] = Bp[i - 1] + ll(B[i] == '1');

	if (Bp.back() == 0) {
		cout << -1 << endl;
		return 0;
	}

	vii series(N, {0, 0});
	{
		set<ll> Bs;
		for (int i = 0; i < N; ++i)
			if (B[i] == '1') {
				Bs.insert(i-N);
				Bs.insert(i);
				Bs.insert(i+N);
			}
		for (int i = 0; i < N; ++i) {
			auto it = Bs.lower_bound(i);
			series[i].second = (*it) - i;
			if ((*it) > i) --it;
			series[i].first = i - (*it);
		}
	}

	for (ll s = -N; s <= 0; ++s) {
		ll cost = -s;
		vii extra(1, {0, 0});
		for (ll i = 0; i < N; ++i) {
			if (A[i] == B[(i-s+N+N)%N]) continue;
			cost++;
			extra.push_back({
				series[i].first,
				max(0LL, series[i].second + s)
			});
		}

		sort(extra.rbegin(), extra.rend());
		ll textra = INF, rmax = 0;
		for (ii pr : extra) {
			textra = min(textra, (ll)pr.first + rmax);
			rmax = max(rmax, (ll)pr.second);
		}
		textra = min(textra, rmax);
		cost += 2 * textra;
		best = min(best, cost);
	}

	for (ll s = 0; s <= N; ++s) {
		ll cost = s;
		vii extra(1, {0, 0});
		for (ll i = 0; i < N; ++i) {
			if (A[i] == B[(i-s+N+N)%N]) continue;
			cost++;
			extra.push_back({
				max(0LL, series[i].first - s),
				series[i].second
			});
		}

		sort(extra.rbegin(), extra.rend());
		ll textra = INF, rmax = 0;
		for (ii pr : extra) {
			textra = min(textra, (ll)pr.first + rmax);
			rmax = max(rmax, (ll)pr.second);
		}
		textra = min(textra, rmax);
		cost += 2 * textra;

		best = min(best, cost);
	}

	cout << best << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;
using PAIR = pair<string, int>;

int main()
{
    int n;
    cin >> n;
    vector<pair<string, int>> vec(n);
    map<pair<string, int>, int> mp;
    for (int i = 0; i < n; i++)
    {
        string s;
        int x;
        cin >> s >> x;
        vec[i] = {s, x};
        mp[{s, x}] = i;
    }

    sort(vec.begin(), vec.end(), [](PAIR l, PAIR r) {
        return l.first < r.first || (l.first == r.first && l.second > r.second);
    });

    for (int i = 0; i < vec.size(); i++)
    {
        cout << mp[vec[i]] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n==0: break
    m = int(input())
    s = input()

    ar = [0]*m
    ans = 0
    if m >= 3:
        for i in range(2,m):
            if s[i-2:i+1] == "IOI":
                ar[i] = ar[i-2] + 1
                if ar[i] >= n: ans += 1
    print(ans)

Measured memory_bytes: 30552
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

struct MaxFlow{
    struct edge{
        int to,cap,rev;
        edge(int t, int c, int r):to(t),cap(c),rev(r){}
    };
    vector<vector<edge>> g;
    vector<bool> used;
    MaxFlow(int n){
        g=vector<vector<edge>>(n);
        used=vector<bool>(n);
    }
    void add(int from, int to, int cap){
        g[from].eb(to,cap,g[to].size());
        g[to].eb(from,0,g[from].size()-1);
    }
    int dfs(int v, int t, int f){
        if(v==t) return f;
        used[v]=true;
        rep(i,g[v].size()){
            auto &e=g[v][i];
            if(!used[e.to] && e.cap>0){
                int d=dfs(e.to, t, min(f,e.cap));
                if(d>0){
                    e.cap-=d;
                    g[e.to][e.rev].cap+=d;
                    return d;
                }
            }
        }
        return 0;
    }
    int calcMF(int s, int t){
        int flow=0;
        while(1){
            fill(all(used),false);
            int f=dfs(s,t,INF);
            if(f==0) return flow;
            flow+=f;
        }
    }
};




int main(){
	int n;
	cin>>n;
	MaxFlow mf(n*2+2);
	vector<pii> p(n);
	rep(i,n){
		cin>>p[i].first>>p[i].sc;
		mf.add(0,i+1,1);
	}
	rep(i,n){
		pii q;
		cin>>q.first>>q.sc;
		rep(j,n){
			if(p[j].fs<q.fs&&p[j].sc<q.sc){
				mf.add(j+1,n+i+1,1);
			}
		}
		mf.add(n+i+1,2*n+1,1);
	}
	cout<<mf.calcMF(0,2*n+1)<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A;
	A.push_back(0);
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}
	A.push_back(0);
	int all_budget = 0;
	for (int i = 0; i <= N; i++) all_budget += abs(A[i] - A[i+1]);
	for (int i = 1; i <= N; i++) {
		int tmp = abs(A[i - 1] - A[i + 1]) - (abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1]));
		cout << all_budget + tmp  << endl;
	}
	return 0;
}

Measured memory_bytes: 1784
#include <stdio.h>
#define MAX 100
 
int main(void) {
    int i, j, sum, n, m, a[MAX][MAX], b[MAX];
    scanf("%d %d", &n, &m);
    for(i = 0; i < n; i++) {
        for(j = 0; j < m; scanf("%d", &a[i][j++]));
    }
    for(i = 0; i < m; scanf("%d", &b[i++]));
    for(i = 0; i < n; i++) {
        for(sum = j = 0; j < m; sum += a[i][j] * b[j++]);
        printf("%d\n", sum);
    }
    return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 16;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

int main() {
	fread(cn, 1, cm, stdin);
	ci = cn;

	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';
	int A[200001] = {};

	int mae = 0;
	int kotae = 1;
	int mod = 1e9 + 7;
	rep(i, N) {
		int C = 0;
		if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') C = C * 10 + ct - '0';
		else while ((ct = *ci++) >= '0') C = C * 10 + ct - '0';
		if (mae != C) kotae = (kotae + *(A + C)) % mod;
		*(A + C) = kotae;
		mae = C;
	}

	int keta = 0;
	char C[10];
	while (kotae) {
		C[keta] = '0' + kotae % 10;
		kotae /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) putchar(C[i]);
	putchar('\n');

	Would you please return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,k,x,y,s=0;
    cin>>n>>k>>x>>y;
    for(int i=1;i<=min(n,k);i++)
        s+=x;
    for(int i=k+1;i<=n;i++)
        s+=y;
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 3612
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    cnt=1
    for i in range(1,n):
        if l[i]>=max(l[:i]):
            cnt+=1
    print(cnt)
resolve()

Measured memory_bytes: 3060
#-*- coding:utf-8 -*-

N = int(input())

mochi_list = []
for i in range(N):
	a = int(input())
	mochi_list.append(a)

mochi_list.sort()

y = -1
num = 0
for i in mochi_list:
	if y < i:
		num += 1
		y = i
	
print(num)




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

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

    const long long INF = 1LL << 60;
    long long dp[100010];

    for (int i = 0; i < 100010; ++i)
    {
        dp[i] = INF;
    }

    dp[0] = 0;
    dp[1] = dp[0] + abs(h[0] - h[1]);

    for (int i = 1; i < n; i++)
    {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>

using namespace std;

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

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

    sort(a, a+n);

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

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>

using namespace std;

int m, n;
bool a[90][90];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ma;

void f(bool a[90][90], int depth, int y, int x)
{
    if (y < 0 || y >= n) return;
    if (x < 0 || x >= m) return;
    if (!a[y][x]) return;

    a[y][x] = 0;

    if (ma < depth) ma = depth;

    for (int i = 0; i < 4; ++i) f(a, depth + 1, y + dy[i], x + dx[i]);

    a[y][x] = 1;
}

int main(void)
{
    while (cin >> m >> n, m || n) {
        memset(a, 0, sizeof(a));
        ma = 0;

        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) for (int j = 0; j < m; ++j) if (a[i][j]) f(a, 1, i, j);

        cout << ma << endl;
    }
}

Measured memory_bytes: 1168
'use strict';
const fs = require('fs');
const mod = BigInt(1e9+7);


class ABC041 {
  static A(input) {
    var s, i
    input = input.trim().split('\n');
    [s, i] = input;
    i = parseInt(i, 10);
    console.log(s[i-1]);
  }
  static B(input) {
    var a, b, c;
    input = input.trim().split(' ').map(BigInt);
    [a, b, c] = input;
    var ans = a * b % mod * c % mod;
    ans = Number(ans);
    console.log(ans);
  }
  static C(input) {
    var [n, height] = input.trim().split('\n');
    height = height.split(' ').map(n => parseInt(n, 10));
    n = parseInt(n, 10);
    var height = Object.keys(height).map(key => [parseInt(key, 10)+1, height[key]]);
    height.sort(function(first, second) {
      return (second[1] - first[1]);
    });
    for (var [i, _] of height) {console.log(i);}
  }
  static D(input) {
    var lines = input.trim().split('\n');
    var [n, m] = lines[0].split(' ').map(x => +x);
    var edges = new Array(n).fill(0);
    for (var i = 0; i < m; i++) {
      var [x, y] = lines[1+i].split(' ').map(x => +x);
      edges[x-1] |= 1<<(y-1);
    }
    var comb = new Array(1<<n).fill(null); comb[0] = 1;
    function count(edges, bit) {
      if (comb[bit] != null) {return comb[bit];}
      comb[bit] = 0;
      for (var i = 0; i < n; i++) {
        if (bit>>i&1 && !edges[i]) {
          var nxt_bit = bit & ~(1<<i);
          var nxt_edges = edges.slice();
          for (var j = 0; j < n; j++) {
            nxt_edges[j] &= ~(1<<i);
          }
          comb[bit] += count(nxt_edges, nxt_bit);
        }
      }
      return comb[bit];
    }
    console.log(count(edges, (1<<n)-1));
  }
}

class ABC173 {
  static A(input) {
    var n = +input.trim();
    console.log(Math.floor((n+999)/1000)*1000 - n);
  }
  static B(input) {
    var lines = input.trim().split('\n');
    var n = +lines[0];
    var cnt = {
      'AC': 0,
      'WA': 0,
      'TLE': 0,
      'RE': 0
    }
    for (var i = 0; i < n; i++) {
      cnt[lines[1+i]]++;
    }
    for (var [verd, c] of Object.entries(cnt)) {
      console.log(`${verd} x ${c}`);
    }
  }
  static C(input) {
  }
  static D(input) {
  }
  static E(input) {
  }
  static F(input) {
  }
}


var input = fs.readFileSync('/dev/stdin', 'utf8');
ABC173.B(input);

Measured memory_bytes: 37280
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++)
        L[i] = A[left + i];
    for (int i = 0; i < n2; i++)
        R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        cnt++;
        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[MAX], n, i;
    cnt = 0;

    cin >> n;
    for (i = 0; i < n; i++)
        cin >> A[i];

    mergesort(A, n, 0, n);

    for (i = 0; i < n; i++)
    {
        if (i)
            cout << " ";
        cout << A[i];
    }
    cout << endl;

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6980
import math
n = int(input())
lst = [int(input()) for i in range(n)]
s = 0

def isprime(x):
    if x == 2:
        return True
    if x < 2 or x%2 == 0:
        return False
    i = 3
    while i <= math.sqrt(x):
        if x%i == 0:
            return False
        i = i+2
    return True

for i in range(n):
    if isprime(lst[i]):
        s += 1

print(s)


Measured memory_bytes: 6016
#include<stdio.h>

void insertionSort(int *,int);
void stateprint(int *,int);

void insertionSort(int *A,int N)
{
    int i,j,v;
    for(i = 1;i < N;i++) {
        v = A[i];
	j = i-1;
        while(j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        stateprint(A,N);
    }
}

void stateprint(int *A,int N)
{
    int i;
    
    for(i = 0;i < N;i++) {
        if(i > 0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

int main()
{
    int i,N,A[1000];
    
    scanf("%d",&N);
    
    for(i =0 ;i < N;i++) 
        scanf("%d",&A[i]);
        
    stateprint(A,N);
    insertionSort(A,N);
    
    return 0;
    
}



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

#define ll long long
#define ld long double
#define xx first
#define yy second
#define vi vector<int>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()

#define MAX 400005

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

    string s;
    cin >> s;

    if(s[2] == s[3] && s[4]==s[5])
        cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

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

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

main() {
  int N; cin >> N;
  ll ans = 1;
  for (int i = 0; i < N; i++) {
    ll T;
    cin >> T;
    ans = T / gcd(ans, T) * ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(ll i=a;i<(b);i++)
#define fj(a,b) for(ll j=a;j<(b);j++)
#define fk(a,b) for(ll k=a;k<(b);k++)


int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
	//int tt;
	//cin>>tt;
	//while(tt--)
	{
		int n;
		cin>>n;
		bool can=false;
		int count=0;
		fi(0,n)
		{
			int x,y;
			cin>>x>>y;
			if(x==y)
			{
				count++;
			}
			else
			{
				count=0;
			}
			if(count>=3)
			{
				can=true;
			}
		}
		if(count>=3) can=true;
		cout<<(can?"Yes":"No")<<'\n';
		
		
		
	}		
}


Measured memory_bytes: 3648
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define PB push_back
#define MP make_pair
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define INF (1<<28)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

bool ans = true;

void judge(string s) {
    int n = s.length();
    for (int i = 0; i < n; i++) {
        if (s[i] != s[n - 1 - i])ans = false;
    }
    return;
}

int main() {
    string s;
    cin >> s;
    judge(s);
    judge(s.substr(0, s.length() / 2));
    judge(s.substr(s.length() / 2 + 1));
    if (ans)Yes;
    else No;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
typedef long long i64;
using namespace std;
i64 S(i64 n) {
	i64 s = 0;
	while (n > 0)
	{
		s += n % 10;
		n /= 10;
	}
	return s;
}
void DigitSums() {
	i64 N;
	cin >> N;
	cout << ((N % S(N) == 0) ? "Yes" : "No") << "\n";

}

int main() {
	DigitSums();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
ll f[N], h[N], n, m, k;
int main()
{
    cin >> n >> k;
    for (ll i = 0; i < n; i++)
        cin >> h[i];
    for (ll i = n - 2; i >= 0; i--)
    {
        m = LONG_MAX;
        for (ll j = i + 1; j < min(i + k + 1, n); j++)
            m = min(f[j] + abs(h[j] - h[i]), m);
        f[i] = m;
    }
    cout << f[0];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll Q=1000000007;
const double PI=3.14159265358979323846;

int main(){
  int M,X,N,Y;
  cin >> M >> X >> N >> Y;
  if(M==N){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
#define llu unsigned long long

int take() {
    int n;
    scanf("%d",&n);
    return n;

}
double ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define Int take()
#define Dnt ttake()
#define LL takes()
#define done {return 0}
#define fr(n) for(int i=1;i<=n;i++)
#define FR(a,b,x) for(int i=(a);i<=(b);i+=(x))
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define vii vector<pii>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)

using namespace std;

bool approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define STR {struct info}
#define dbg(x) {cout<<"ekhane"<<x<<endl;}
#define  SS second
#define  FF first
#define PQ priority_queue
#define great greatest
#define less lesser
#define mii map<int,int>
#define mil map<int,ll>
#define mll map<ll,ll>
#define msb map<string,bool>
#define M 100005
//////////////////////////////////////////



int main() {

    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s>=t) printf("No\n");
    else printf("Yes\n");
    return 0;
}




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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

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


void solve(){
  int N;
  int A[2*100000+5];

  cin >> N;
  rep(i, N){
    cin >> A[i];
    A[i]--;
  }

  int count[2*100000+5] = {};
  rep(i, N){
    count[A[i]]++;
  }

  ll sum = 0;
  rep(i, N){
    sum += count[i] * (count[i] - 1ll) / 2;
  }

  rep(i, N){
    cout << sum - count[A[i]] + 1 << endl;
  }
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main(){
    int n;
    cin >> n;
    if(n == 1) cout << 0 << endl;
    else if(n == 0) cout << 1 << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    string s; cin >> s;
    int n = s.size();
    rep(i,n) {
        if (i+1 < n) {
            if (s[i] == s[i+1]) {
                cout << i+1 << " " << i+2 << endl;
                return 0;
            }
        }
        if (i+2 < n) {
            if (s[i] != s[i+1] && s[i] == s[i+2]) {
                cout << i+1 << " " << i+3 << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << endl;
}

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

int main() {
  int N, Y;
  cin >> N >> Y;
  bool ok = false;
  int a = -1, b = -1, c = -1;
  for (int i = 0; i <= Y/10000; i++) {
    int y = Y - i*10000;
    int n = N - i;
    for (int j = 0; j <= y/5000; j++) {
      int y2 = y - j*5000;
      int n2 = n - j;
      if (1000*n2 == y2) {
        ok = true;
        a = i;
        b = j;
        c = n2;
        break;
      }
    }
  }
  cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int dice(int a, int b){
		int count = 0;
		string tpat[3];
		tpat[0] = "12651";
		tpat[1] = "23542";
		tpat[2] = "13641";
		int ret[3];
		ret[0] = 3;
		ret[1] = 1;
		ret[2] = 5;
		for(int i = 0; i < 3; i++){
				for(int j = 0; j < 4; j++){
						if(tpat[i][j] - '0' == a && tpat[i][j+1] - '0' == b){
								return ret[i];
						}
				}
		}
		tpat[0] = "15621";
		tpat[1] = "24532";
		tpat[2] = "14631";
		for(int i = 0; i < 3; i++){
				for(int j = 0; j < 4; j++){
						if(tpat[i][j] - '0' == a && tpat[i][j+1] - '0' == b){
								return 7 - ret[i];
						}
				}
		}

}

int main(int argc, char const* argv[])
{
	int d[6];
	for(int i = 0; i < 6; i++){
			cin >> d[i];
	}
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
			int a, b;
			cin >> a >> b;
			int a1, b1;
			for(int i = 0; i < 6; i++){
					if(d[i] == a)a1 = i;
					if(d[i] == b)b1 = i;
			}
			cout << d[dice(a1+1, b1+1)-1] << endl;
	}
	return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define len length()
int res = 0;
struct Trie {
    Trie * pipe[26];
    bool last ;
    Trie(){
        for(int i =0;i<26;i++){
            this->pipe[i]=nullptr;
        }
        last=false;
    }
    void insert(const string &s){
        Trie * node  = this;
        int next;
        for(int i=0;i<s.len;i++){
            next = s[i]-'a';
            if (node->pipe[next]==nullptr) node->pipe[next]= new Trie();
            node = node->pipe[next];
        }
        if (node->last==false){
            res++;
            node->last=true;
        }
    }
};
int main(){
    int n;
    cin>>n;
    Trie trie;
    string s;
    while(n--){
        cin>>s;
        trie.insert(s);
    }
    cout<<res;
}


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

struct Card {char suit,value;};
int main() {  
 	int N;
  	cin >>N;
	char ch;
  	Card C1[100],C2[100];
  	for(int i=0;i<N;i++){
    	cin >>C1[i].suit>>C1[i].value;
      	C2[i]=C1[i];
    }
  // bubble sort
  for(int i=0;i<N;i++){
  	for(int j=N-1;j>=i+1;j--){
    	if(C1[j].value<C1[j-1].value){
        Card x=C1[j];C1[j]=C1[j-1];C1[j-1]=x;
        }
    }  
  } 
  // selection sort
  for(int i=0;i<N;i++){
  	int minj=i;
  	for(int j=i;j<N;j++){
    	if(C2[j].value<C2[minj].value)minj=j;
    	
    }
  	Card t=C2[i];C2[i]=C2[minj];C2[minj]=t;
  }
  
  for(int i=0;i<N;i++){
  if(i!=0)cout <<" ";  
  cout<<C1[i].suit<<C1[i].value;
  }
  cout <<endl<<"Stable"<<endl;
  
  int flag=0;
  for(int i=0;i<N;i++){
     if(C2[i].suit!=C1[i].suit){flag=1;}
    }
  
  for(int i=0;i<N;i++){
  if(i!=0)cout <<" ";  
  cout<<C2[i].suit<<C2[i].value;
  }
  cout <<endl;
  if(flag==0){cout <<"Stable"<<endl;}
  else{cout <<"Not stable"<<endl;}
}


Measured memory_bytes: 3132
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
vector<string> s;

ll dfs(int &i, int j){
  if (isdigit(s[i][j])){
    ll res = s[i][j] - '0';
    i++;
    return res;
  }
  if (s[i][j] == '+'){
    ll res = 0;
    i++;
    while (i < n && j < s[i].size() && s[i][j] == '.'){
      res += dfs(i, j + 1);
    }
    return res;
  }
  if (s[i][j] == '*'){
    ll res = 1;
    i++;
    while (i < n && j < s[i].size() && s[i][j] == '.'){
      res *= dfs(i, j + 1);
    }
    return res;
  }
  assert(false);
}

int main(){
  while (cin >> n, n){
    s.resize(n);
    each(x, s) cin >> x;
    int i = 0;
    cout << dfs(i, 0) << endl;
  }
}

Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(int (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(int (i)=(a)-1;(i)>=(b);(i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define VI vector<int>
#define VII vector<VI>
#define VL vector<LL>
#define VLL vector<VL>
#define VD vector<double>
#define VDD vector<VD>
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<LL,LL>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define EP emplace_back
#define FORE(a,b) for(auto &&a:b)

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF=1e9;
const int MOD=INF+7;
#define int LL
signed main (void){
    int a,b; cin>>a>>b;
    if(a>0 && b>0){
        cout<<"Positive"<<endl;
    }else if((a<=0 && b>=0)||(a>=0 && b<=0)){
        cout<<"Zero"<<endl;
    }else{
        if(a<0 && b<0){
            if((b-a)%2==0){
                cout<<"Negative"<<endl;
            }else{
                cout<<"Positive"<<endl;
            }
        }
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x;
        long min = 10000000;
        long max = -10000000;
        long sum = 0;
        for(int i = 0; i < n; i++){
            x = sc.nextInt();

            sum+= x;
            
            if(min > x){
                min = x;
            }
            if(max < x){
                max = x;
            }
        }
        System.out.println(min + " " + max + " " + sum);
    }
}


Measured memory_bytes: 43088
n = int(input())
s = input()

W = [0]*n
E = [0]*n

for i in range(n-1):
    if s[i]=='W':
        W[i+1]+=1
    W[i+1]+=W[i]
for i in range(n-1,0,-1):
    if s[i]=='E':
        E[i-1]+=1
    E[i-1]+=E[i]

ans=float('inf')
for i in range(n):
    ans=min(ans,W[i]+E[i])

print(ans)

Measured memory_bytes: 27040
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>

using namespace std;

int main()
{
    int N, X;
    cin >> N;
    X = ceil(N / 1.08);
    if (N == trunc(X * 1.08)) {
        cout << X << endl;
    }
    else {
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<time.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
#define INF (1<<30)
#define INFLL (1LL << 60)
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

#define PRIME_RANGE 100001
bitset<PRIME_RANGE> isPrime;
void calcPrime() {
	for (int i = 2; i < PRIME_RANGE; ++i) isPrime.set(i);
	for (int i = 2; i < PRIME_RANGE; ++i) {
		if (isPrime[i]) {
			for (int j = i * 2; j < PRIME_RANGE; j += i) {
				isPrime.reset(j);
			}
		}
	}
}

int main()
{
	int Q; cin >> Q;
	vector<int> accum(PRIME_RANGE + 1, 0);
	vector<int> like(PRIME_RANGE, 0);
	calcPrime();
	for (int i = 2; i < PRIME_RANGE; ++i) {
		if (isPrime[i] && isPrime[(i + 1) / 2]) {
			like[i] = 1;
			++accum[i];
		}
		accum[i + 1] = accum[i];
	}
	rep(i, Q) {
		int l, r; cin >> l >> r;
		cout << accum[r] - accum[l - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 3300
N = int(input())
w = input().split()
w = [int(w_) for w_ in w]

sum_ = sum(w)
min_ = sum_
for i in range(N-1):
    sum2 = sum(w[:i+1])
    min_ = min([abs(sum2-(sum_-sum2)),min_])
print(min_)

Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

def Fibo(n):
	S = [1, 1]
	if n == 1:
		return 1
	for i in range(1, n):
		S.append(S[i] + S[i-1])

	return S[n]

if M == 0:
	print(Fibo(N)%mod)
	exit()

a = [INT()]
for i in range(1, M):
	a.append(INT())
	if a[i] == a[i-1]+1:
		print(0)
		exit()
m = [a[0]-1]
for i in range(1, M):
	m.append(a[i]-a[i-1]-2)
m.append(N-a[M-1]-1)



ans = 1
for n in m:
	ans *= Fibo(n)

print(ans%mod)

Measured memory_bytes: 462032
#include <stdio.h>

int main(void){
	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	printf((x >= r && x <= W-r) && (y >= r && y <= H-r) ? "Yes\n" : "No\n");

	return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll *a = new ll[n];
	ll* b = new ll[n];
	int tmp = 0;
	while (n--)
		cin >> a[tmp++];
	b[0] = a[0];
	for (int i = 1; i < tmp; i++)
		b[i] =b[i-1]+ a[i];
	ll min = abs(b[tmp-1] - 2 * b[0]);
	for (int i = 1; i < tmp - 1; i++)
		min =((min > abs(b[tmp-1] - 2 * b[i])) ? (abs(b[tmp-1] - 2 * b[i])) : min);
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
bool cmp(int x,int y)
{
    return x>y;
}
int main()
{
    int n,sum=0;
    scanf("%d",&n);
    int a[2][101],b[101]={0},i,j;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[0][i]);
    }
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[1][i]);
    }
    sum=sum+a[0][0]+a[1][n-1];//一定经过左上角和右下角，所以可以提前加上
    for(i=0;i<n-1;i++)//从第i个开始转入第二行
    {
        for(j=i;j<n-1;j++)
        {
            b[i]=b[i]+a[1][j];//加第二行数据
        }
        for(j=0;j<i;j++)
        {
            b[i]=b[i]+a[0][j+1];//加第一行数据
        }
    }
    sort(b,b+(n-1),cmp);
    sum=sum+b[0];//加上和最大的那条路的数据
    printf("%d\n",sum);
    return 0;
}

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

int main(void) {
    int N;
    long long ans = 1, mod = pow(10, 9) + 7;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        ans *= i;
        ans %= mod;
    }

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

Measured memory_bytes: 256
#分岐は後で処理すれば良い
#それぞれ0,nに近づくのが最適
import sys
sys.setrecursionlimit(10**8)
from heapq import heappush,heappop
inf=10**10
n=int(input())
l=[[] for i in range(n+1)]
for i in range(n-1):
  a,b=map(int,input().split())
  l[a].append(b)
  l[b].append(a)
prev=[-1 for i in range(n+1)]
def dijkstra(s):
  q=[(0,s)]
  dist=[inf]*(n+1)
  dist[s]=0
  while q:
    c,v=heappop(q)
    if dist[v]<c:
      continue
    for i in l[v]:
      t=i
      cost=1
      if dist[v]+cost<dist[t]:
        dist[t]=dist[v]+cost
        prev[t]=v
        heappush(q,[dist[t],t])
  return dist
d=dijkstra(1)
p=[n]
num=n
next=[-1 for i in range(n+1)]
while num!=1:
  num1=prev[num]
  next[num1]=num
  p.append(num1)
  num=num1
countp=[0]
countf=[0]
def dfs(x,y):
  for i in l[x]:#iに分岐可能ならば
    if prev[x]!=i and next[x]!=i:
      if y==1:
        countp[0]+=1
      else:
        countf[0]+=1
      prev[i]=x
      dfs(i,y) 
p=p[::-1]
num=len(p)
num1=(num-1)//2+1
for i in range(num1):
  countp[0]+=1
  dfs(p[i],1)
for i in range(num1,num):
  countf[0]+=1
  dfs(p[i],0)
if countp[0]>countf[0]:
  print("Fennec")
else:
  print("Snuke")

Measured memory_bytes: 28440
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> A(3);
  cin>>A[0]>>A[1]>>A[2];
  sort(ALL(A));
  cout<<A[0]+A[1]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  char b;
  cin>>b;
  if(b=='A') cout<<"T"<<endl;
  else if(b=='T') cout<<"A"<<endl;
  else if(b=='G') cout<<"C"<<endl;
  else if(b=='C') cout<<"G"<<endl;
}

Measured memory_bytes: 256
// package abc127.c

import scala.io.StdIn

object Main {

  def main(args: Array[String]) {
    val Array(n, m) = StdIn.readLine().split(" ").map(e => e.toInt)
    val Array(l, r) = (1 to m).toList.foldLeft(Array(1, n))((arr, i) => {
      arr match {
        case Array(l, r) => {
          val Array(nl, nr) = StdIn.readLine().split(" ").map(e => e.toInt)
          Array(if (l < nl) nl else l, if (nr < r) nr else r)}
      }
    })
    val ans = r - l + 1
    println(if (ans < 0) 0 else ans)
  }

}


Measured memory_bytes: 73584
def merge_sort(arr, left, right)
  return 0 unless left + 1 < right

  count = 0

  mid = (left + right) / 2

  count += merge_sort(arr, left, mid)
  count += merge_sort(arr, mid, right)
  count += merge(arr, left, mid, right)

  count
end

def merge(arr, left, mid, right)
  count = 0

  n1 = mid - left
  n2 = right - mid

  left_arr = arr[left, n1]
  right_arr = arr[mid, n2]

  left_arr << Float::INFINITY
  right_arr << Float::INFINITY

  i = j = 0
  k = left

  while k < right
    if left_arr[i] <= right_arr[j]
      arr[k] = left_arr[i]
      i += 1
    else
      arr[k] = right_arr[j]
      j += 1
      count += n1 - i
    end

    k += 1
  end

  count
end

if $PROGRAM_NAME == __FILE__
  n = gets.to_i

  arr = gets.chomp.split.map(&:to_i)

  puts merge_sort(arr, 0, n)
end

Measured memory_bytes: 40884
s = input()
n = len(s)
s_1 = s[:(n-1)//2]
s_2 = s[(n+3)//2 - 1:]
if s == s[::-1] and s_1 == s_1[::-1] and s_2 == s_2[::-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
import numpy as np
a = input()
b = a.split()
N = int(b[0]) # num of people
M = int(b[0]) # num of food
list = []
list_new = []
s = input()
s = s.split()
K = int(s[0])
for i in range(1,K+1):
    list_new.append(int(s[i]))
for i in range(1,N):
    list = list_new
    list_new = []
    s = input()
    s = s.split()
    s = s[1:]
    for item in s:
        if int(item) in list:
            list_new.append(int(item))
        else:
            pass
print(len(list_new))

Measured memory_bytes: 18372
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	AB := sc.nextInts()
	if AB[0] >= 10 || AB[1] >= 10 {
		fmt.Println(-1)
		return
	}
	fmt.Println(AB[0] * AB[1])
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
//写一个将二维数组传入函数的函数
#include<stdio.h>
int a,n;
long long sum,q[200010];
void quick_sort(long long q[],int l,int r)
{
    if(l>=r) return;
    int x=q[l],i=l-1,j=r+1;
    while(i<j){
        do i++;
        while(q[i]<x);
        do j--;
        while(q[j]>x);
        if(i<j){
            int temp=q[i];
            q[i]=q[j];
            q[j]=temp;
        }
    }
    quick_sort(q,l,j);
    quick_sort(q,j+1,r);
}

int main(void)
{
    scanf("%d%d",&n,&a);
    for(int i=1;i<=n;i++)
        scanf("%lld",&q[i]);
    quick_sort(q,1,n);
    for(int i=1;i<=n-a;i++)
        sum+=q[i];
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
string t;
int dp[20][20];
int get(string x,string y)
{
    memset(dp , 0 , sizeof(dp));
    //cout<<x<<' '<<y<<' '<<t<<endl;
    dp[0][0] = 1;
    for(int i = 0;i <= x.size();i++){
        for(int j = 0;j <= y.size();j++){
            if(i == 0 && j == 0) continue;
            if(i > 0 && x[i - 1] == t[i + j - 1]) dp[i][j] += dp[i - 1][j];
            if(j > 0 && y[j - 1] == t[i + j - 1]) dp[i][j] += dp[i][j - 1];
            //printf("%d ",dp[i][j]);
        }
        //cout<<endl;
    }
    return dp[x.size()][y.size()];
}
int main()
{
    scanf("%d",&n);cin>>s;
    for(int i = n;i < s.size();i++) t += s[i];
    reverse(t.begin() , t.end());
    long long ans = 0;
    for(int i = 0;i < (1<<n);i++){
        string x , y;
        for(int j = 0;j < n;j++){
            if((i>>j) & 1) x += s[j];
            else y += s[j];
        }
        ans += get(x , y);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
//  ^_^
#include<bits/stdc++.h>
using namespace std;
#define Om ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
int main()
{
    Om;
    ll a, c, d, b, x, y, ans;
    cin>>a>>b>>c>>d;
    ans = max(a*d, a*c);
    
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout<< ans <<endl;
    return 0;
}




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

long long int N, M, X;

long long int C[17];
long long int A[17][17];

long long int knowledge[17];

long long tryPoss(int toRead)
{
	long long cost = 0;
	for(int i = 0; i < N; i++)
	{
		if( (toRead & (1 << i)) > 0)
		{
			//printf("toRead = %d, %d, %d\n", toRead, (1 << i), toRead & (1 << i));
			cost += C[i + 1];
			for(int j = 1; j <= M; j++)
				knowledge[j] += A[i + 1][j];
		}
	}
	
	for(int j = 1; j <= M; j++)
	{
		if(knowledge[j] < X)
			return -1;
	}
	
	return cost;
}

int main()
{
	scanf("%lld%lld%lld", &N, &M, &X);
	
	for(int i = 1; i <= N; i++)
	{
		scanf("%lld", &C[i]);
		
		for(int j = 1; j <= M; j++)
			scanf("%lld", &A[i][j]);
	}
	
	bool possible = false;
	long long ans = 0;
	
	for(int i = 0; i <= 4100; i++)
	{
		for(int j = 0; j < 17; j++)
			knowledge[j] = 0;
		
		long long temp = tryPoss(i);
		
		if(temp == -1)
			continue;
			
		if(!possible)
		{
			possible = true;
			ans = temp;
		}
		
		else
			ans = min(ans, temp);
	}
	
	if(!possible)
		printf("-1");
		
	else
		printf("%lld", ans);
}

Measured memory_bytes: 3824
S = input()

cnt = [0]*3

for s in S:
    cnt[ord(s)-97] += 1

cnt.sort()
ans = "YES"
prepre = -1
pre = -1

while cnt != [0]*3:
    for i in range(3)[::-1]:
        if cnt[i] > 0:
            if prepre == i or pre == i:
                ans = "NO"
            cnt[i] -= 1
            prepre = pre
            pre = i

print(ans)

Measured memory_bytes: 3188
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> al = new ArrayList<>();
		List<Integer> avg = new ArrayList<>();
		
		int n, sum, cnt;
		while(true) {
			sum = 0;
			cnt = 0;
			n = sc.nextInt();
			
			if(n == 0)	break;
			
			for(int i = 0; i < n; i++) {
				al.add(sc.nextInt());
			}
			
			Collections.sort(al);

			for(int i = 1; i < n - 1; i++) {
				sum += al.get(i);
				cnt++;
			}
			
			avg.add(sum / cnt);
			al.clear();
		}
		
		for(int i: avg) {
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 28836