akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define rep(i,n) for(int(i)=0; (i)<(n); (i)++)

using namespace std;

int main(){
    char ABCD[4];
    rep(i,4) cin >> ABCD[i];

    int A = ABCD[0]-48;
    int B = ABCD[1]-48;
    int C = ABCD[2]-48;
    int D = ABCD[3]-48;

    char ope[]={'+', '-'};
    rep(i,2) rep(j,2) rep(k,2)
        if( A + (i?-B:B) + (j?-C:C) + (k?-D:D) == 7 ){
            cout << A << ope[i] << B << ope[j] << C << ope[k] << D << "=7\n";
            return 0;
        }

}

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

int main(){
    while(1){
        int h,w;
        cin >> h >> w;
        if(h==0) break;
        
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

int main(void){
  int N;
  string s;
  cin >> N;
  cin >> s;
  int i,count=0;
  REP(i,N){
    if(s[i] == 'R') count++;
  }
  if(count > N/2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;
vector<P1> A;

signed main(){
    cin>>N;
    for(int i=0;i<N;++i){
        int a;
        cin>>a;
        A.push_back(P1(a,i));
    }
    sort(A.begin(),A.end(),greater<P1>());
    for(int i=0;i<N;++i){
        if(A[0].second!=i)cout<<A[0].first<<endl;
        else cout<<A[1].first<<endl;
    }
}


Measured memory_bytes: 6128
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,k;
	string s;
	cin>>n>>k>>s;
	if(s[k-1]=='A'){
		s[k-1]='a';
	}
	if(s[k-1]=='B'){
		s[k-1]='b';
	}
	if(s[k-1]=='C'){
		s[k-1]='c';
	}
	cout<<s<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    string s;
    cin>>k>>s;
int siz=s.size();
if(siz<=k){
    cout<<s<<endl;
}
else{
    for(int i=0;i<k;i++){
        cout<<s.at(i);
    }
cout<<"...";
}
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 2000005
#define ll long long
#define ld double
#define mod 998244353
using namespace std;
char inp[maxn];
struct th
{
	ll a[maxn];
	th()
	{
		memset(a, 0, sizeof(a));
	}
	void add(int pl, int num)
	{
		a[pl] += num;
	}
	void build()
	{
		for(int i = 1; i < maxn; i++)
			a[i] += a[i - 1];
	}
	ll q(int l, int r)
	{
		return a[r] - a[l - 1];
	}
}q1, q2;
int k[maxn];
int sum[maxn];
int main()
{
	int n;
	scanf("%d", &n);
	scanf("%s", inp + 1);
	for(int i = 1; i <= n; i++)
	{
		sum[i] = sum[i - 1];
		if(inp[i] == 'M') sum[i]++;
		if(inp[i] == 'C') q1.add(i, 1), q2.add(i, sum[i]);
	}
	q1.build(), q2.build();
	int q;
	scanf("%d", &q);
	for(int i = 0; i < q; i++)
	{
		int k;
		scanf("%d", &k);
		ll ans = 0;
		for(int j = 1; j <= n; j++)
			if(inp[j] == 'D')
				ans += q2.q(j, j + k - 1) - sum[j] * q1.q(j, j + k - 1); 
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 37888
import sys

l = raw_input().split()
N = int(l[0])
M = int(l[1])
C = int(l[2])

B = raw_input().split()
A = [[]*M]*N

for n in range(N):
    A[n] = raw_input().split()

correct = 0

for n in range(N):
    answer = C
    An = A[n]
    for m in range(M):
        answer += int(An[m]) * int(B[m])
    if answer > 0:
        correct += 1

print(correct)


Measured memory_bytes: 2568
#include<stdio.h>

int main(void) {
  int a[3];
  int i = 0,min = 10000,max = 0;
  for (i = 0;i < 3;++i) {
    scanf("%d",&a[i]);
  }
  for (i = 0;i < 3;++i) {
    if (a[i] < min) {
      min = a[i];
    }
  }
  for (i = 0;i < 3;++i) {
    if (a[i] > max) {
      max = a[i];
    }
  }
  printf("%d",abs(max - min));
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B, C;
    cin >> A >> B >> C;
    if(A + B >= C) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3628
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
ll n, m, a, b, x, y;
ll f(ll x, ll y)
{
    return x * n + y;
}
const ll INF = (1LL << 62) - 1;
vector<ll> dijkstra(vector<vector<pair<ll, ll>>> &G, ll v)
{
    vector<ll> ans(G.size(), INF);
    ans[v] = 0;
    auto cmp = [&](ll i, ll j) { return ans[i] > ans[j]; };
    priority_queue<ll, vector<ll>, decltype(cmp)> que(cmp);
    que.push(v);
    while (!que.empty())
    {
        auto f = que.top();
        que.pop();
        for (auto i : G[f])
            if (ans[f] + i.second < ans[i.first])
                ans[i.first] = ans[f] + i.second, que.push(i.first);
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> n >> m;
    cin >> x >> y >> a >> b;
    x--, y--, a--, b--;
    vector<string> s(n);
    vector<vector<pair<ll, ll>>> g(N);
    for (auto &e : s)
        cin >> e;
    for (ll i = 0; i < n; i++)
        for (ll j = 0; j < m; j++)
            if (s[i][j] == '.')
            {
                if (i < n - 1 && s[i + 1][j] == '.')
                    g[f(i, j)].push_back({f(i + 1, j), 0});
                if (i && s[i - 1][j] == '.')
                    g[f(i, j)].push_back({f(i - 1, j), 0});
                if (j < m - 1 && s[i][j + 1] == '.')
                    g[f(i, j)].push_back({f(i, j + 1), 0});
                if (j && s[i][j - 1] == '.')
                    g[f(i, j)].push_back({f(i, j - 1), 0});
                for (ll x = -2; x < 3; x++)
                    for (ll y = -2; y < 3; y++)
                        if (i + x < n && j + y < m && i + x >= 0 && j + y >= 0 && s[i + x][j + y] == '.')
                            g[f(i, j)].push_back({f(i + x, j + y), 1});
            }
    auto d = dijkstra(g, f(x, y));
    cout << (d[f(a, b)] == INF ? -1 : d[f(a, b)]);
}

Measured memory_bytes: 205964
#include <stdio.h>
#include <string.h>
char str[10];
int main(void)
{
	scanf("%s", str);
	switch(str[1])
	{
		case 'U':
			if(str[0] == 'S')
			{
				printf("7\n");
			}else{
				printf("5\n");
			}
			break;
		case 'O':
			printf("6\n");
			break;
//		case 'U':
		case 'E':
			printf("4\n");
			break;
		case 'H':
			printf("3\n");
			break;
		case 'R':
			printf("2\n");
			break;
		case 'A':
			printf("1\n");
			break;

	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)

// for debug macro
bool global_debug_flag = false;
#define DEBUG(val) \
  if (global_debug_flag) cout << #val << " = " << val << endl

int main() {
  int n;
  cin >> n;
  string s = "APPROVED";
  vector<int> data(n);
  REP(i, n) {
    int x;
    cin >> x;
    data[i] = x;
  }
  REP(i, n) {
    // cout << data[i] << endl;
    if (data[i] % 2 == 0) {
      bool flag1 = (data[i] % 3 == 0);
      bool flag2 = (data[i] % 5 == 0);
      if ((flag1 == false) && (flag2 == false)) {
        s = "DENIED";
      }
    }
    // cout << s << endl;
  }

  cout << s << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N,T)= readLine()!!.split(" ").map(String::toInt)
    var minCost=1001;
    repeat(N){
        val (c,t)= readLine()!!.split(" ").map(String::toInt)
        if(t<=T && c<minCost){
            minCost=c;
        }
    }

    if(minCost!=1001) {
        println(minCost)
    }else{
        println("TLE")
    }


}

Measured memory_bytes: 37956
#include <iostream>
using namespace std;
 
int main(){
  int A,B,C,D,Answer = 0;
  cin >> A; cin >> B ; cin >> C; cin >> D;
  if (A >= B){
  	Answer += B;
  }else{
    Answer += A;
  }
    if (C >= D){
  	Answer += D;
  }else{
    Answer += C;
  }
  cout << Answer <<endl;
}

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int W, H;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
struct S{
  char grid[10][10];
  int t;
};
bool end(char grid[][10]){
  REP(y, H) REP(x, W) if( grid[y][x] != grid[0][0]) return false;
  return true;
}
void filling(int x, int y, char from, char to, char grid[][10]){
  grid[y][x] = to;
  REP(r, 4){
    int nx = x + dx[r];
    int ny = y + dy[r];
    if(nx >= 0 && ny >= 0 && nx < W && ny < H && grid[ny][nx] == from){
      grid[ny][nx] = to;
      filling(nx, ny, from, to, grid);
    }
  }
}
int main(){
  while(cin>>W>>H && W){
    S start;
    start.t = 0;
    REP(y, H)REP(x, W) cin>>start.grid[y][x];
    queue<S> que;
    que.push(start);
    while(!que.empty()){
      S s = que.front(); que.pop();
      string color = "RGB";
      if(end(s.grid)) {
        cout<<s.t<<endl;
        goto END;
      }
      REP(i, 3) if(color[i] != s.grid[0][0]){
        S next = s;
        next.t += 1;
        filling(0, 0, s.grid[0][0], color[i], next.grid);
        que.push(next);
      }
    }
END:;
  }
  return 0;
}

Measured memory_bytes: 25000
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        int times, time_count;
        while(sc.hasNext()){
            String word = sc.next();
            if(word.equals("-")) break;
               times = sc.nextInt();
            for(int i = 0; i < times; i++){
                time_count = sc.nextInt();
                word = word.substring(time_count, word.length()) + word.substring(0, time_count);
            }
            System.out.println(word);
        }
    }
}


Measured memory_bytes: 26284
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
long long a,b;
int main(){
    cin>>a>>b;
    a--;
    long long f,s;
    if(a%4==2)
        f=a+1;
    if(a%4==3)
        f=0;
    if(a%4==0)
        f=a;
    if(a%4==1)
        f=1;
    if(b%4==2)
        s=b+1;
    if(b%4==3)
        s=0;
    if(b%4==0)
        s=b;
    if(b%4==1)
        s=1;
    cout<<(f^s)<<endl;
    return 0;
}

Measured memory_bytes: 256
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

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

#define ios ios_base::sync_with_stdio(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)

const long long MXN = 1e6 + 100;
const long long MNN = 4444;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long OO = 1e9 + 1;
const double pi = acos(-1.0);

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, b[MXN], sum, mx;

int main(){
    ios;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        sum += b[i];
        mx = max(b[i], mx);
    }
    llong x = n * (n + 1) / 2;
    if(sum % x != 0){
        cout << "NO";
        return 0;
    }
    int k = sum / x;
    for(int i = 1; i < n; i++){
        llong d = b[i + 1] - b[i];
        if(k - d >= 0 && (k - d) % n == 0){
            continue;
        }else{
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}
/*
 
1 1 - 1
2 1 - 1
3 1 - 1
4 1 - 1
5 1 - 1
6 1 - 1
7 1 - 1
 
1 2 - 0
2 2 - 1
3 2 - 2
4 2 - 3
5 2 - 4
6 2 - 5
7 2 - 6
 
1 3 - 1
2 3 - 1
3 3 - 1
4 3 - 3
5 3 - 6
6 3 - 10
7 3 - 15
8 3 - 21
9 3 - 28
10 3 - 36
 
1 4 - 1
2 4 - 1
3 4 - 1
4 4 - 1
5 4 - 4
6 4 - 10
7 4 - 20
8 4 - 35
9 4 - 56
10 4 - 84

1 5 - 1
2 5 - 1
3 5 - 1
4 5 - 1
5 5 - 1
5 5 - 1
6 5 - 5
7 5 - 15
8 5 - 35
9 5 - 70
10 5 - 126
*/


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
int a[100];	int n;
pair<int,int>Out[1500];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int mx=-(1<<30);int mn=(1<<30);int pm,pn;
	for(register int i=1;i<=n;i++)
		if(a[i]>mx)	mx=a[i],pm=i;
	for(register int i=1;i<=n;i++)
		if(a[i]<mn) mn=a[i],pn=i;
	if(a[pm]+a[pn]>0){
		printf("%d\n",2*n);
		printf("%d %d\n",pm,1);
			printf("%d %d\n",pm,1);
			for(int i=1;i<n;i++){
				printf("%d %d\n%d %d\n",i,i+1,i,i+1);
			}		
	}
	else {
		printf("%d\n",2*n);
		printf("%d %d\n",pn,n);
		printf("%d %d\n",pn,n);
			for(int i=n-1;i>=1;i--){
				printf("%d %d\n%d %d\n",i+1,i,i+1,i);
			}	
	}
	return 0;
}

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

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

typedef long long ll;

int main() {
	int a, p;
	cin >> a >> p;
	cout << (3 * a + p) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))

im = 0
m = 10**20
B = []
C = []
for i,a in enumerate(A):
    if a<m:
        m=a
        im=i
    B.append(a-m)
    C.append(im)

maxB = max(B)
print(len({c for b,c in zip(B,C) if b==maxB}))

Measured memory_bytes: 14692
#include <bits/stdc++.h>
using namespace std;
bitset <2000*2000+5> b;
int sum,x,i,n;
int main()
{
	b[0]=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		b|=b<<x;
		sum+=x;
	}
	for(i=(sum+1)/2;!b[i];i++);
	printf("%d",i);
}

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

int main() {
    ll n;
    cin>>n;
    ll a[n-1];
    ll co[n];
    rep(i,n){
        co[i] = 0;
    }
    rep(i,n-1){
        cin>>a[i];
        co[(a[i]-1)] += 1;
    }
    rep(i,n){
        cout<<co[i]<<endl;
    }
}

Measured memory_bytes: 6764
#include <stdio.h>

int A[1000000],G[1000000];
int n,count,glen;

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

void shellSort(int *A,int n){
  int h=1,i=0;
  while(1){
    if(h > n) break;
    G[i] = h;
    h = 3*h + 1;
    i++;
  }
  glen = i;
  for(i = glen-1;i >= 0;i--) insertionSort(A,n,G[i]);
}

int main(){
  int i;
  scanf("%d",&n);
  for(i = 0;i < n;i++) scanf("%d",&A[i]);
  count = 0;
  shellSort(A,n);

  printf("%d\n",glen);
  for(i = glen - 1;i >= 0;i--){
    printf("%d",G[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  for(i = 0;i < n;i++) printf("%d\n",A[i]);

  return 0;
}

Measured memory_bytes: 6372
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def calc(V, es, r):
    mins = [(10**18, -1)]*V
    for s, t, w in es:
        mins[t] = min(mins[t], (w, s))
    mins[r] = (-1, -1)

    group = [0]*V
    comp = [0]*V
    cnt = 0

    used = [0]*V
    for v in range(V):
        if not used[v]:
            chain = []
            cur = v
            while cur!=-1 and not used[cur]:
                chain.append(cur)
                used[cur] = 1
                cur = mins[cur][1]
            if cur!=-1:
                cycle = 0
                for e in chain:
                    group[e] = cnt
                    if e==cur:
                        cycle = 1
                        comp[cnt] = 1
                    if not cycle:
                        cnt += 1
                if cycle:
                    cnt += 1
            else:
                for e in chain:
                    group[e] = cnt
                    cnt += 1

    if cnt == V:
        return sum(map(lambda x:x[0], mins)) + 1

    res = sum(mins[v][0] for v in range(V) if v!=r and comp[group[v]])

    n_es = []
    for s, t, w in es:
        gs = group[s]; gt = group[t]
        if gs == gt:
            continue
        if comp[gt]:
            n_es.append((gs, gt, w - mins[t][0]))
        else:
            n_es.append((gs, gt, w))
    return res + calc(cnt, n_es, group[r])

def solve():
    N, M = map(int, readline().split())
    V = []
    D = []
    for i in range(M):
        *Vi, = map(float, readline().split())
        d = sum(e**2 for e in Vi)
        if d <= 1e-9:
            continue
        V.append(Vi)
        D.append(d)

    M = len(V)
    E = []
    for i in range(M):
        Vi = V[i]
        for j in range(M):
            if i == j:
                continue
            Vj = V[j]
            t = 0
            for k in range(N):
                t += Vi[k] * Vj[k]
            r = t / (D[j])
            c = 0
            for k in range(N):
                c += (Vi[k] - r*Vj[k])**2
            E.append((j+1, i+1, c))
        E.append((0, i+1, D[i]))
    write("%.16f\n" % calc(M+1, E, 0))
solve()


Measured memory_bytes: 33204
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;
ll max(ll a, ll b){return a > b ? a : b;}
ll min(ll a, ll b){return a < b ? a : b;}

int a[100001];
vector<int> neg, pos;
vector<pair<int,int> > out;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x, a;
    cin >> x >> a;
    if(x<a) cout << 0;
    else cout << 10;
}

//TODO: 56
//come back to 50D, 55D, DP-J



Measured memory_bytes: 256
import java.util.*;

public class Main{

  static boolean check1(String s){
    for(int i=0; i<s.length()/2; i++){
      if (!(s.charAt(i) == s.charAt(s.length()-1-i)))
        return false;
    }
    return true;
  }

  static boolean check2(String s){
    for(int i=0; i<(s.length()-1)/4; i++){
      if (!(s.charAt(i) == s.charAt((s.length()-1)/2 -1-i)))
        return false;
    }
    return true;
  }

  static boolean check3(String s){
    for(int i=(s.length()+3)/2-1; i<s.length(); i++){
      if (!(s.charAt(i) == s.charAt(s.length()-1-i)))
        return false;
    }
    return true;
  }

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    if(check1(s) && check2(s) && check3(s))
      System.out.println("Yes");
    else 
      System.out.println("No");
  }
}


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

#define ll long long int
using namespace std;
int main()
{
    ll n,i,j,k,a,p,c=0,d,y,l;
    vector<ll>v[20];
    cin>>n>>d;
    for(i=0;i<n;i++)
    {
        for(j=0;j<d;j++)
        {
            cin>>k;
            v[i].push_back(k);
        }
    }
    for(i=0;i<n-1;i++)
    {

        for(j=i+1;j<n;j++)
        {
            y=0;
            for(l=0;l<d;l++)
            {
                y+=(v[i][l]-v[j][l])*(v[i][l]-v[j][l]);
            }
            double f=(double)y;
            if(ceil(sqrt(f))==floor(sqrt(f)))
            {
                c++;
            }

        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int[]L = new int[N];
			for(int i = 0;i<N;i++)L[i] = scan.nextInt();
			Arrays.sort(L);
			long goukei = 0;
			
			
			for(int i = 0;i<N-1;i++) {
				for(int j = i+1;j<N;j++) {
					int hidari = Math.abs(L[i]-L[j]);
					int H = upperbound(L,hidari);
					//System.out.print(i+" "+j+" ");
					//System.out.print(upperbound(L,hidari));
					//System.out.print(" ");
					
					int migi = L[i]+L[j];
					int M = lowerbound(L,migi)-1;
					//System.out.println(lowerbound(L,migi)-1);
					
					
					int akouho = 0;//lowerbound(L,migi)-upperbound(L,hidari)+1;
					
					//if(H<=i&&i<=M) akouho--;
					if(H<=j&&j<=M) akouho=M-j;
					
							goukei+=akouho;
					
				}
			}
			
			
			System.out.println(goukei);
			
		}
		
		
	}
	
	
	//2部探索で便利なメソッド
	
	/*値valueがソートされた数列arrの何番目以上かを表示するメソッド
	 * 両方のメソッドとも同じ値を見つけられなかったらそれよりも大きい値の中の最小の番号をいう
	 * 両方ともvalueが前配列より小さかったら０、大きかったらarr[]の最大の番号＋１を表示する。
	 * lowerboundは数列の中から値を発見するのにも便利
	 * arrはソートされた配列
	 * 計算量はlog(o(n))
	 * */
	public static int lowerbound(int [] arr, int value){//value以上のarrたち
        int left = 0;//左端は探索したい物の一番左端の番号を選択
        int right = arr.length;//右端は探索したい物の一番右端の番号+1を選択(重要)
        while (left<right){
            int mid = (left+right)/2;
            if (arr[mid]<value){
                left = mid+1;
            }else {//こっちが同じ値を含む条件、見つけたらright側が保持してleftがR=Lになるまでどんどん近づくイメージ
                right = mid;
            }
        }
        return left;
    }
	
	//lowerboundと仕様が違うので要注意
	//配列が大きすぎて作れない場合がほとんどなので無理にメソッドとして使わなくてもいい、考えは同じ

    public static int upperbound(int[] arr, int value){//valueより大きいarrたちの中の一番目を出力
        int left = 0;//左端は探索したい物の一番左端の番号を選択
        int right = arr.length;//右端は探索したい物の一番右端の番号+1を選択(重要)
        while (left<right){
            int mid = (left+right)/2;
            if (arr[mid]<=value){//見つけたら一個先の番号をleftが保持しrightがR=Lになるまでどんどん近づいてくるイメージ
                left = mid+1;
            }else {
                right = mid;
            }
        }
        return left;
    }
    
		

}


Measured memory_bytes: 26760
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	// 入力
	ll N;
	cin >> N;
	ll A[N];
	for (ll i = 0; i < N; ++i) cin >> A[i];
 
	// 解法
	ll num_gcd = A[0];
	REP(i,N){
		num_gcd = gcd(num_gcd, A[i]);
	}
	cout << num_gcd << endl;
}

Measured memory_bytes: 1024
class UnionFindNode(object):
    def __init__(self, group_id, parent=None, value=None):
        self.group_id_ = group_id
        self.parent_ = parent
        self.value = value
        self.rank_ = 1
    def __str__(self):
        template = "UnionFindNode(group_id: {}, \n\tparent: {}, value: {}, size: {})"
        return template.format(self.group_id_, self.parent_, self.value, self.rank_)

    def is_root(self):
        return not self.parent_

    def root(self):
        parent = self
        while not parent.is_root():
            parent = parent.parent_
            self.parent_ = parent
        return parent

    def find(self):
        root = self.root()
        return root.group_id_

    def rank(self):
        root = self.root()
        return root.rank_

    def unite(self, unite_node):
        root = self.root()
        unite_root = unite_node.root()
        if root.group_id_ != unite_root.group_id_:
            if root.rank() > unite_root.rank():
                unite_root.parent_ = root
                root.rank_ = max(root.rank_, unite_root.rank_ + 1)
            else:
                root.parent_ = unite_root
                unite_root.rank_ = max(root.rank_ + 1, unite_root.rank_)

n,q=map(int,input().split())
a=[0 for i in range(n)]
for i in range(n):
    a[i]=UnionFindNode(i)
for i in range(q):
    first,second=map(int,input().split())
    a[first-1].unite(a[second-1])
count=[0 for i in range(n)]
for i in range(n):
    count[a[i].find()]+=1
print(max(count))

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

const int MAXN = int(1e5);

int N;
vector<int> G[MAXN];

signed main() {
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i + 1 < N; ++i) {
    int a, b;
    cin >> a >> b;
    G[a - 1].emplace_back(b - 1);
    G[b - 1].emplace_back(a - 1);
  }
  static int dis[MAXN], pre[MAXN];
  {
    queue<pair<int, int>> que;
    que.emplace(dis[0] = 0, 0);
    memset(pre, -1, sizeof(pre));
    while (not que.empty()) {
      int d, u;
      tie(d, u) = que.front();
      que.pop();
      for (int v: G[u]) {
        if (dis[v] > d + 1) {
          que.emplace(dis[v] = d + 1, v);
          pre[v] = u;
        }
      }
    }
  }
  static int col[MAXN];
  col[0] = 1, col[N - 1] = 2;
  {
    int x = dis[N - 1] - 1 >> 1;
    for (int i = pre[N - 1], c = 0; i != -1; i = pre[i], ++c) { 
      col[i] = c < x ? 2 : 1;
    }
    queue<int> que;
    for (int i = 0; i < N; ++i) {
      if (col[i]) {
        que.emplace(i);
      }
    }
    while (not que.empty()) {
      int u = que.front();
      que.pop();
      for (int v: G[u]) {
        if (col[v] == 0) {
          col[v] = col[u];
          que.emplace(v);
        }
      }
    }
  }
  int a = 0;
  for (int i = 0; i < N; ++i) {
    a += col[i] == 1;
  }
  if (a > N / 2) {
    cout << "Fennec\n";
  } else {
    cout << "Snuke\n";
  }
  return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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 T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

vllvll grid(4, vll(4));

int main()
{
        rep(i, 1, 4) rep(j, 1, 4) cin >> grid[i][j];

        rep(a1, -50, 51) {
                rep(a2, -50, 51) {
                        rep(a3, -50, 51) {
                                bool flg = true;
                                ll b1 = grid[1][1] - a1;
                                ll b2 = grid[2][2] - a2;
                                ll b3 = grid[3][3] - a3;
                                vllvll tmp(2, vll(3));
                                tmp[0] = {a1, a2, a3};
                                tmp[1] = {b1, b2, b3};
                                rep(i, 1, 4) {
                                        rep(j, 1, 4) {
                                                if (grid[i][j] != tmp[0][i-1] + tmp[1][j-1]) flg = false;
                                        }
                                }
                                if (flg) {
                                        cout << "Yes" << endl;
                                        return 0;
                                }
                        }
                }
        }
        cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

ll dp[1001][10001];
int main(void) {
    ll h, n;
    cin >> h >> n;
    vector<ll> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];

    REP(i, n+1) REP(j, h+1) dp[i][j] = INF;
    dp[0][0] = 0;
    REP(i, n) {
        REP(j, h+1) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(h, j+a[i])], dp[i+1][j]+b[i]);
        }
    }
    cout << dp[n][h] << endl;

    return 0;
}

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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)

int main(){
  int a, b;
  cin >> a >> b;
  cout << (a < 10 && b < 10 ? a * b : -1) << endl;
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
c=0
l=[]
for i in range(m-1):
    l.append(abs(x[i]-x[i+1]))
l.sort()
if len(l)-n+1<=0:
    print("0")
else:
    for i in range(len(l)-n+1):
        c+=l[i]
    print(c)

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

using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long A,B;
    cin >> A >> B;
    char C; cin>>C;
    int D; cin >>D;
    B*= 100; B += D;
    long long X = A*B;
    X /= 100;
    cout << X << "\n";
    
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    int n,m;
    cin >> n >> m;
    set<ll> x;
    set<ll> y;
    for(int i = 0;i < n;i++){
        ll tmp;
        cin >> tmp;
        x.insert(tmp);
    }
    rep(i,m){
        ll tmp;
        cin >> tmp;
        y.insert(tmp);
    }
    mint delx = 0;
    mint cnt = 1;
    for(auto itr = x.begin();itr!=x.end();itr++){
        delx += (cnt-1) * mint(*itr);
        delx -= (mint(n)-cnt) * mint(*itr);
        cnt += 1;
    }
    mint dely = 0;
    cnt = 1;
    for(auto itr = y.begin();itr!=y.end();itr++){
        dely += (cnt-1) * mint(*itr);
        dely -= (mint(m)-cnt) * mint(*itr);
        cnt += 1;
    }
    mint ans = delx * dely;
    cout << ans << endl;
    return 0;
}

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

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

    long health[n];

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

    if(k>n)
        cout<<"0";
    else{
    sort(health,health+n,greater<int>());
    long long summ=0;

    for(int i=k;i<n;i++)
        summ+=health[i];

        cout<<summ;
    }

    return 0;

}

Measured memory_bytes: 1792
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    string S;
    cin >> S;
    int N = S.size();
    map<int, int> M;
    M[0]++;
    int i_ten = 1, last_mod = 0;
    rep(i, N){
        int a = ((S.at(N - 1 - i) - '0') * i_ten + last_mod) % 2019;
        last_mod = a;
        i_ten = (i_ten * 10) % 2019;
        M[a]++;
    }

    ll ans = 0;
    for(auto m : M){
        ll tmp = m.second;
        ans += tmp * (tmp - 1) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
ll n;
cin >> n;
vector<ll>a(n),b(n),c(n);
for(int i=0;i<n;i++){cin>>a.at(i);}
for(int i=0;i<n;i++){cin>>b.at(i);}
for(int i=0;i<n;i++){cin>>c.at(i);}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
sort(c.begin(),c.end());
ll ans = 0;
for(int i=0;i<n;i++){
    ll key = b.at(i);
    ll ok = -1,ng=n;
    while(abs(ng-ok)>1){
        ll mid = (ok+ng)/2;
        if(a.at(mid)<key)ok = mid;//al = ok
        else ng =mid;
    }
    ll ngg=-1,okk=n;
    while(okk-ngg>1){
        ll mid = (okk+ngg)/2;
        if(c.at(mid)>key)okk=mid;// cr = okk
        else ngg =mid;
    }
    ans+=(n-okk)*(ok+1);
}
cout << ans << endl;
}




Measured memory_bytes: 2560
/****************************** بسم الله الرحمن الرحيم ************************/
/*---------------------------------------------------------------------*/
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#define ordered_set tree<pair<int, int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define compare bool operator <
#define main int main()
#define sf(n) scanf ("%d", &n)
#define pf(n) printf ("%d", n)
#define sfl(n) scanf ("%lld", &n)
#define pfl(n) printf ("%lld", n)
#define pfnewline() printf("\n")
#define pfspace() printf(" ")
#define mem(x,y) memset( (x), (y), sizeof(x) )
#define max3(a,b,c)   max(a , max(b,c) )
#define min3(a,b,c)  min(a, min(b,c) )
#define Ex 2.718281828
#define pi acos(-1.0)
#define toDecimal(n) fixed<< setprecision(n)
#define rep1(i, n) for(int i = 1; i<=n;i++)
#define rep(i, n) for(int i = 0; i<n;i++)
#define sfc(ch) scanf("%c",&ch)
#define sfs(ch) scanf("%[^\n]%*c", ch);

const ll mxn = 1e5+3;

/** ---8 moves --- **/
//int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
//int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/** ---4 moves--**/
//int dx[] = {-1,0,0,1};
//int dy[] = {0,-1,1,0};

using namespace __gnu_pbds;
using namespace std;

main
{
    int n;
    cin >> n;
    int a[n+5];
    mem(a,0);
    rep(i,n)
    {
        cin >> a[i];
    }
    int ans[n+5];
    mem(ans,500005);
    ans[0] = 0;
    for(int i = 0; i<n-1;i++)
    {
        ans[i+1] = min(ans[i+1],  ans[i]+ ( abs( a[i] - a[i+1]  ) ) );
        ans[i+2] = min(ans[i+2],  ans[i]+ ( abs( a[i] - a[i+2]  ) ) );
    }

    cout << ans[n-1] << endl;
}



Measured memory_bytes: 1024
#include <cstdlib>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
  char *line = NULL;
  size_t buffer_size = 0;
  while (getline(&line, &buffer_size, stdin) > 0) {
    int weight = atoi(line);

    vector<int> counter_weights;
    for (int i = 0; weight != 0 && i < 10; ++i) {
      int mask = 1 << i;
      if (weight & mask) { counter_weights.push_back(mask); }
      weight &= ~mask;
    }
    for (auto iter = counter_weights.begin();
         iter != counter_weights.end();
         ++iter) {
      printf("%d%c", *iter, iter + 1 == counter_weights.end() ? '\n' : ' ');
    }
  }
  free(line);

  return 0;
}

Measured memory_bytes: 996
#include <stack>
using namespace std;

struct Rectangle {
  int height;
  int pos;
};
 

#include <stdio.h>
#define SIZ 1400
int m[SIZ+1][SIZ+1];
int st[SIZ];
char z[9999999];
int get(){
	static int input_count=0;
	int r=0;
	for(;'0'<=z[input_count]&&z[input_count]<='9';)r=r*10+z[input_count++]-'0';
	input_count++;
	return r;
}
int main(){
	fread(z,1,sizeof(z),stdin);
	int i,j,k,y=get(),x=get(),r,ptr;
	for(j=0;j<y;j++)for(r=i=0;i<x;m[j][i]=r,i++){
		int t=get();
		r=t==0?r+1:0;
	}
	r=0;
/*
	for(i=0;i<x;i++)for(ptr=j=0;j<=y;j++){
		//printf("%d %d %d %d\n",i,j,ptr,m[j][i]);
		if(!ptr || st[ptr-1]<m[j][i])st[ptr++]=m[j][i];
		else{
			for(;ptr && st[ptr-1]>m[j][i];){
				int _y=(j-(ptr-1)),_x=st[--ptr];
				//printf("%d %d\n",_x,_y);
				if(r<_x*_y)r=_x*_y;
			}
			st[ptr++]=m[j][i];
		}
	}
*/
	Rectangle rect;
	for(int i=0;i<x;i++){
		stack<Rectangle> stk;
		//rect.height = 0;
		//rect.pos = 0;
		//stk.push(rect);
		int pop=0;
		for(int j=0;j<=y;j++){
			rect.height = m[j][i];
			rect.pos = j;
			if(stk.empty() || stk.top().height <= rect.height){
				stk.push(rect);
			}else{
				//printf("[-] %d %d\n",i,j);
				for(;!stk.empty() && stk.top().height > rect.height;){
					pop++;
					Rectangle pre = stk.top(); stk.pop();
					//pre.pos=stk
					int area = pre.height * (j - pre.pos);
					r = max(r, area);
					//printf("%d %d\n",target,pre.pos);
					rect.pos = pre.pos;
				}
				stk.push(rect);
			}
			if(rect.height==0)pop=0;
		}
	}

	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 14336
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

string S;

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

  int ans = 0;
  string s_prev = "";
  for (int i = 0; i < S.size(); i++) {
    string s{S[i]};
    if (s != s_prev) {
      ans++;
    } else {
      if (i + 1 < S.size()) {
        s += S[i + 1];
        ans++;
        i++;
      }
    }
    s_prev = s;
  }

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

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

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

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

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

  int cnt = 0;
  rep(i, N) {
    int p;
    std::cin >> p;
    if(p != i + 1) ++cnt;
  }

  if(cnt <= 2) std::cout << "YES" << '\n';
  else std::cout << "NO" << '\n';
}


Measured memory_bytes: 256
n,m,x=map(int,input().split())
book=[list(map(int,input().split())) for i in range(n)]
ans=10**7
for i in range(2**n):
    l=[0]*(m+1)
    for j in range(n):
        if (i>>j&1):
            for k in range(m+1):
                l[k]+=book[j][k]
        if all(l[i]>=x for i in range(1,m+1)):
            if l[0]<ans:
                ans=l[0]
if ans==10**7:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9212
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using P = pair<int, int>;
vector<P> res;
void f(vector<P> v) {
    if (res.size() == 8) return;
    if (v.size() == 8) {
        res = v;
        return;
    }
    rep(x, 8) rep(y,8){
        vector<P> p;
        rep(i, v.size()) {
            if (v[i].first == x) goto END;
            if (v[i].second == y) goto END;
            if (abs(v[i].first - x) == abs(v[i].second - y)) goto END;
        }
        p = v;
        p.push_back(P(x, y));
        f(p);
    END:
        continue;
    }    
}
int main() {
    int N;
    cin >> N;
    vector<P> p(N);
    rep(i, N) cin >> p[i].second >> p[i].first;
    f(p);
    sort(res.begin(), res.end(), [](const P& a, const P& b) {if (a.second == b.second) return a.first < b.first; return a.second < b.second; });
    rep(i, 8) {
        string s;
        rep(j, 8) s.push_back(res[i].first == j ? 'Q' : '.');
        cout << s << endl;
    }
    return 0;
}




Measured memory_bytes: 3240
#include <iostream>


using namespace std;

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r >= 0 && y-r >=0 && x+r <=w && y+r <=h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3092
from sys  import stdin,stdout

st=lambda:list(stdin.readline().strip())
li=lambda:list(map(int,stdin.readline().split()))
mp=lambda:map(int,stdin.readline().split())
inp=lambda:int(stdin.readline())
pr=lambda n: stdout.write(str(n)+"\n")

mod=1000000007

def solve():
    a,b,c,d=mp()
    x=a*d
    y=a*c
    z=b*d
    p=b*c
    pr(max(x,y,z,p))
    


for _ in range(1):
    solve()


Measured memory_bytes: 9128
// https://atcoder.jp/contests/abc118/tasks/abc118_d
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const string MINUSINF = "-";

void chmax(string &a, string b) {
    if (a == MINUSINF)
        a = b;
    else if (a.size() < b.size())
        a = b;
    else if (a.size() == b.size()) {
        if (a < b)
            a = b;
    }
}

const long long match[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
vector<string> dp;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; ++i)
        cin >> A[i];

    // 初期化
    dp = vector<string>(11000, MINUSINF);

    // 初期条件
    dp[0] = "";

    // DP ループ
    for (int i = 0; i <= N; ++i) {
        if (dp[i] == MINUSINF)
            continue;
        for (auto a : A)
            chmax(dp[i + match[a]], dp[i] + (char)('0' + a));
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 43648
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

ll gcd(ll a,ll b){
	ll c;
	while(a%b){
		ll c = b;
		b = a%b;
		a = c;
	}
	return b;
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin >> a >> b;
	cout << a * b / gcd(a,b) << endl;
}

Measured memory_bytes: 256