akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

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

	cout << "Yes" << endl;

}

Measured memory_bytes: 640
#!/usr/bin/env python3


def next_line():
    return input()


def next_int():
    return int(input())


def next_int_array_one_line():
    return list(map(int, input().split()))


def next_int_array_multi_lines(size):
    return [int(input()) for _ in range(size)]


def next_str_array(size):
    return [input() for _ in range(size)]


def main():
    r, c, k = map(int, input().split())
    dp = [[[0] * (c+1) for i in range(r+1)] for i in range(4)]
    v = [[0] * (c+1) for i in range(r+1)]
    for i in range(k):
        row, col, val = map(int, input().split())
        v[row][col] = val

    for row in range(1, r + 1):
        for col in range(1, c + 1):
            for num in range(0, 4):
                if num == 0:
                    dp[num][row][col] = dp[3][row-1][col]  # simple down
                else:
                    
                    dp[num][row][col] = max(dp[num-1][row][col],  # str
                                            dp[num][row][col-1],  # right x
                                            dp[3][row-1][col] + \
                                            v[row][col],  # down o
                                            dp[num-1][row][col-1] + \
                                            v[row][col],  # right o
                                            )
    print(dp[3][r][c])


if __name__ == '__main__':
    main()


Measured memory_bytes: 430180
import sys
sys.setrecursionlimit(2147483647)
input=sys.stdin.readline
import math
from heapq import heappush, heappop, heapify

def solve(n, nodes):
  xsort_nodes = sorted(nodes, key=lambda n: n[1])
  ysort_nodes = sorted(nodes, key=lambda n: n[2])
  edges = [[] for _ in range(n)]
  for i in range(n-1):
    prev_node = xsort_nodes[i]
    post_node = xsort_nodes[i+1]
    edges[prev_node[0]].append((abs(prev_node[1]-post_node[1]), post_node[0]))
  for i in range(n-1):
    prev_node = ysort_nodes[i]
    post_node = ysort_nodes[i+1]
    edges[prev_node[0]].append((abs(prev_node[2]-post_node[2]), post_node[0]))
  for i in range(1, n):
    prev_node = xsort_nodes[i-1]
    post_node = xsort_nodes[i]
    edges[post_node[0]].append((abs(prev_node[1]-post_node[1]), prev_node[0]))
  for i in range(1, n):
    prev_node = ysort_nodes[i-1]
    post_node = ysort_nodes[i]
    edges[post_node[0]].append((abs(prev_node[2]-post_node[2]), prev_node[0]))
  tree = [0]*n
  tree[0] = 1
  distance = 0
  current_edges = [*edges[0]]
  heapify(current_edges)
  while(len(current_edges)):
    d, x = heappop(current_edges)
    if tree[x]:
      continue
    distance += d
    tree[x] = 1
    for edge in edges[x]:
      heappush(current_edges, edge)
  return distance  

def main():
  n = int(input())
  nodes = []
  for i in range(n):
    x, y = map(int, input().split(' '))
    nodes.append((i, x, y))
  ans = solve(n, nodes)
  print(ans)
  

if __name__=='__main__':
  main()

Measured memory_bytes: 78028
#include <bits/stdc++.h>
    using namespace std;
    int main() {
      long int sum = 0;
      int k;
      cin >> k;
      int i, j, m;
      for (i = 1; i <= k; i++)
        for (j = 1; j <= k; j++)
          for (m = 1; m <= k; m++)
            sum += __gcd(__gcd(i, j), m);
      cout << sum << endl;
      return 0;
    }

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<tuple>
#include<stack>
#include<iomanip>
#include<map>
using namespace std;

int main() {
	int n, i, j,k;
	char s[100];
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> s[i];
	}
	int ans;
	int max = 0;
	for (i = 0; i < n - 1; i++) {
		ans = 0;
		for (j = 0; j <= i; j++) {
			int pre = 0;
			int h,check;
			check = 0;
                  if(j!=0){
			for (h = 0; h < j; h++) {
				if (s[j] == s[h]) check++;
			}
                      }
				for (k = i + 1; k < n; k++) {
					if (s[j] == s[k] && pre == 0&&check==0) pre++;
				}
			ans = ans + pre;
		}
		if (max < ans) max = ans;
	}
	cout<<max;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int D, T, S;
	cin >> D >> T >> S;
	int dist = S * T;
	if (D <= dist)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int M, K; cin >> M >> K;
    if (K >= (1 << M) || (M == 1 && K == 1)) {
        cout << -1 << '\n';
    } else if (K == 0) {
        for (int i = 0; i < (1 << M); i++) {
            cout << i << ' ' << i << ' ';
        }
        cout << '\n';
    } else {
        cout << K << ' ';
        for (int i = 0; i < (1 << M); i++) if (i != K) {
            cout << i << ' ';
        }
        cout << K << ' ';
        for (int i = (1 << M)-1; i >= 0; i--) if (i != K) {
            cout << i << ' ';
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 1792
MyString=Union{String,SubString{String},Char}
MyStringArray=Union{Array{String,1},Array{SubString{String},1},Array{Char,1}}
parseInt(x::MyString) = parse(Int, x)
parseInt(x::Real) = trunc(Int, x)
parseBigInt(x::MyString) = parse(BigInt, x)
parseBigInt(x::Real) = trunc(BigInt, x)
parseFloat(x::MyString) = parse(Float64, x)
parseFloat(x::Real) = trunc(Float64, x)
parseBigFloat(x::MyString) = parse(BigFloat, x)
parseBigFloat(x::Real) = trunc(BigFloat, x)
parseMap(x::MyStringArray) = map(parseInt, x)
parseMapBig(x::MyStringArray) = map(parseBigInt, x)

function main()
    n,l=parseMap(split(readline()))
    s=sort([chomp(readline()) for i in 1:n])
    println(reduce(*,s))
end
main()

Measured memory_bytes: 116240
N, M = map(int, input().split())
A_list = list(map(int, input().split()))
A_list.sort(reverse=True)

check_num = A_list[M - 1]
if check_num / sum(A_list)  >= 1 / (4 * M):
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;


int main(){
    string s;
    cin>>s;
    if(s=="ani") cout<<"square1001"<<endl;
    else cout<<"e869120"<<endl;
    return 0;
}


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

#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE fast()
#define to_str to_string
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMIN INT_MIN
#define IMAX INT_MAX
#define pow POW
#define INF 1e9

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;

void fast() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
}

bool compare(pii &a, pii &b) {
	return a.F > b.F;
}

ll numOfDigits(ll n) {
	if (!n) return 1;
	return (ll) (log10(n)) + 1;
}

ll POW(ll a, ll b);

/*

*/

ll BN();

int main()
{
    THINK_TWICE_CODE_ONCE;
    //freopen("test cases\\.txt", "r", stdin) ;
    double l; cin>>l;
    double a = l/3;
    cout<<fixed<<setprecision(7);
    cout<<a*a*a;
    return 0;
}

ll BN() {
	int low = 1, up = 0;
	int ans = -1;
	while (low <= up) {
		ll mid = (((ll)low + up) / 2);
		if (mid){
			ans = mid;
			low = mid + 1;
		} else
			up = mid - 1;
	}
	return ans;
}

ll POW(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}


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

int main(){
  int N,K; cin>>N>>K;
  int a[110000];
  int count=0;
  for(int i=0;i<N;++i){
    cin>>a[i];
    if(a[i]>=K)count++;
  }

  cout<<count<<endl;
  return 0;
}


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

int main() {
  string s;
  cin>>s;
  int N=s.size()-2;
  for(int i=N;i>0;i-=2){
    if(s.substr(0,i/2)==s.substr(i/2,i/2)){
      cout<<i;
      break;
    }
  }
}


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

int main(){
	int n,g = 0;
	scanf("%d",&n);
	int a[100],b[100];
	for(int i = 0; i < n;i++){
		scanf("%d",&a[i]);
	}
	for(int i = 0; i < n;i++){
		b[i] = i+1;
	}	
	int s = 0;
	for(int i = 0; i < n;i++){
		if(a[i] != b[i]) s++;
	}	
	if(s == 0 || s == 2)printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, K; cin >> N >> K;
    vector<ll> a(N);
    rep(i, N){
        cin >> a[i];
    }


    ll ans = INF;
    rep(i, N){
        if(i + K - 1 >= N) break;
        ll tmp = 0;
        if(a[i + K - 1] >= 0 && a[i] < 0){
            tmp = abs(0 - a[i]) + abs(a[i] - a[i + K - 1]);
            ans = min(ans, tmp);
            tmp = abs(0 - a[i + K - 1]) + abs(a[i + K - 1] - a[i]);
        }else if(a[i] < 0){
            tmp = abs(0 - a[i]);
        }else if(a[i] >= 0){
            tmp = abs(0 - a[i + K - 1]);
        }
        // cout << i << " tmp: " << tmp << endl;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    char a, b; cin >> a >> b;
    if (a == 'H' && b == 'H') cout << 'H' << endl;
    else if (a == 'H' && b == 'D') cout << 'D' << endl;
    else if (a == 'D' && b == 'H') cout << 'D' << endl;
    else cout << 'H' << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

struct edge {
  int to;
  int cost;
};

int N, M, P;
vector<edge> E[2555];
vector<int> G[2555];
bool used[2555];
ll inf = 1 << 30;
int point[2555];

bool bellman_ford(int s) {
  // if a negative loop that can be reached from s exists, return true
  fill(point, point + N, inf);
  point[s] = 0;
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < E[i].size(); j++) {
        edge e = E[i][j];
        if (point[i] != inf && point[e.to] > point[i] + e.cost) {
          point[e.to] = point[i] + e.cost;
          if (k >= N - 1 && used[e.to])
            return true;
        }
      }
    }
  }
  return false;
}

void reachable(int s) {
  used[s] = true;
  queue<int> que;
  que.push(s);
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int n : G[v]) {
      if (!used[n]) {
        used[n] = true;
        que.push(n);
      }
    }
  }
}

void add_edge(int s, int t, int cost) {
  E[s].push_back(edge{t, cost});
}

int main() {
  cin >> N >> M >> P;
  vector<int> A(M), B(M), C(M);
  for (int i = 0; i < M; ++i) {
    cin >> A[i] >> B[i] >> C[i];
    A[i]--;
    B[i]--;
    add_edge(A[i], B[i], P - C[i]);
    G[B[i]].push_back(A[i]);
  }
  reachable(N - 1);
  if (bellman_ford(0))
    cout << -1 << endl;
  else
    cout << max(0, -point[N - 1]);
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950

int main() {
	int K, N; std::cin >> K >> N;
	std::vector<int> A(N);
	for (auto& r : A) std::cin >> r;
	std::vector<int> Dis(N);
	Dis[0] = A[0] + K - A[N - 1];
	for (auto i = 1; i < N; ++i) {
		Dis[i] = A[i] - A[i - 1];
	}
	std::sort(Dis.begin(), Dis.end());
	int sum = 0;
	for (auto& r : Dis)
		sum += r;
	std::cout << sum - Dis[N - 1] << std::endl;
	return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){

  
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y=x;
    if(z->key < x->key)x = x->left;
    else x = x->right;
  }
  z->parent = y;
   if(y == NIL)
      root = z;
    else if(z->key < y->key)
		y->left = z;
    else 
      y->right = z;

  
}
void inorder(Node u){
if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);  
    inorder(u->right);
      }
    
}
void preorder(Node u){
 if(u != NIL){
   printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
      }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 24040
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  using D = tuple<int, int, int>;
  vector<D> data;
  rep(i, N) {
    int x, y;
    char d;
    cin >> x >> y >> d;

    int dir = 0;
    if (d == 'D' || d == 'U') {
      dir |= 2;
    }
    if (d == 'D' || d == 'L') {
      dir |= 1;
    }
    data.push_back(D(x, y, dir));
  }

  constexpr int INF = numeric_limits<int>::max();
  int result = INF;

  constexpr int MAX = 200'000;
  vector<vector<vector<int>>> tbl(4, vector<vector<int>>(MAX + 1));
  vector<vector<vector<int>>> cross(4, vector<vector<int>>(2 * MAX + 1)),
      cross2(4, vector<vector<int>>(2 * MAX + 1));
  rep(i, N) {
    int x, y, d;
    tie(x, y, d) = data[i];

    tbl[d][((d & 2) ? x : y)].push_back((d & 2) ? y : x);
    cross[d][x + y].push_back(x - y + MAX);
    cross2[d][x - y + MAX].push_back(x + y);
  }
  rep(i, 4) irep(j, MAX) { sort(tbl[i][j].begin(), tbl[i][j].end()); }

  rep(i, 4) irep(j, 2 * MAX) {
    sort(cross[i][j].begin(), cross[i][j].end());
    sort(cross2[i][j].begin(), cross2[i][j].end());
  }

  rep(i, 2) {
    irep(j, MAX) {
      for (int v : tbl[i << 1][j]) {
        const auto &tmp = tbl[(i << 1) ^ 1][j];
        auto iter = lower_bound(tmp.begin(), tmp.end(), v);
        if (iter != tmp.end()) {
          // cerr << i << " " << j << " " << v << " " << *iter << "\n";
          chmin(result, 5 * (*iter - v));
        }
      }
    }
  }

  rep(i, 2) {
    irep(j, 2 * MAX) {
      for (int v : cross[i][j]) {
        const auto &tmp = cross[i ^ 2][j];
        auto iter = lower_bound(tmp.begin(), tmp.end(), v);
        if (i == 0) {
          if (iter != tmp.end()) {
            cerr << i << " " << j << " " << v << " " << *iter << "\n";
            chmin(result, 5 * (*iter - v));
          }
        } else {
          if (iter != tmp.begin()) {
            chmin(result, 5 * (v - *prev(iter)));
          }
        }
      }
    }
  }

  rep(i, 2) {
    irep(j, 2 * MAX) {
      for (int v : cross2[i][j]) {
        const auto &tmp = cross2[i ^ 3][j];
        auto iter = lower_bound(tmp.begin(), tmp.end(), v);
        if (i == 0) {
          if (iter != tmp.end()) {
            chmin(result, 5 * (*iter - v));
          }
        } else {
          if (iter != tmp.begin()) {
            chmin(result, 5 * (v - *prev(iter)));
          }
        }
      }
    }
  }

  if (result == INF) {
    cout << "SAFE" << endl;
  } else {
    cout << result << endl;
  }
  return 0;
}

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

const int MOD=1000000007;

int main() {
  int n; cin>>n;
  string s1,s2; cin>>s1>>s2;
  vector<bool> num;
  int r=0;
  while (r < n) {
    if(s1[r]==s2[r]) {
      num.push_back(true);
	  r++;
	} else {
	  num.push_back(false);
	  r+=2;
	}
  }
  ll ans=3;
  rep(i, num.size()) {
    if (i == 0) {
      if(!num[i]) ans = 6;
      continue;
	}
	if (num[i]&&num[i-1]) ans*=2;
    else if (num[i]&&!num[i-1]) ans*=1;
    else if (!num[i]&&num[i-1]) ans*=2;
	else if (!num[i]&&!num[i-1]) ans*=3;
	ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 1000041
using namespace std;

ll mp[mxn];
int main()
{
    FLASH
    ll n;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i],mp[a[i]]++;
    ll cnt = n;
    if(mp[1] == 1)
    {
        cout << "1";
        return 0;
    }
    else if(mp[1] >= 2)
    {
        cout << "0";
        return 0;
    }
    for(int i = 0; i < n; i++)
    {
        ll x = a[i];
        if(mp[a[i]] >= 2)
        {
            cnt--;
            continue;
        }
        for(int j = 2; j * j <= x; j++)
        {
            if(x % j == 0)
            {
                if(mp[j] >= 1 || mp[x / j] >= 1)
                {
                    cnt--;
                    break;
                }
            }
        }
    }
    cout << cnt << '\n' ;
    return 0;
}


Measured memory_bytes: 12916
#include <bits/stdc++.h>
 
using namespace std;
 
#define BOOST        std::ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define sp           <<" "<<
#define ll           long long
#define ld           long double
#define P(x,y)       pair < x,y >
#define V(x)         vector < x >
#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define PI           3.14159265358979323846264338327950288419716939937510
 
const ll mod=1e9+7,N=1e6+5;

int main() 
{ 
    BOOST
    
    int n;
    cin>>n;
    int a[n];

    for(int i=0;i<n;i++)
        cin>>a[i];
    
    int ans[n];
    ans[0]=0,ans[1]=abs(a[1]-a[0]);

    for(int i=2;i<n;i++)
        ans[i]=min( abs(a[i-1]-a[i])+ans[i-1], abs(a[i-2]-a[i])+ans[i-2] );
    cout<<ans[n-1]<<"\n";
    return 0; 
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int M;
  ll K;
  cin >> M >> K;
  if(K == 0) {
    rep(i, 1<<M) cout << i << ' ' << i << ' ';
    cout << "\n";
  } else {
    ll xorall = 0;
    rep(i, 1<<M) xorall ^= i;
    rep(j, 1<<M) {
      if(K == j && K == (xorall^j)) {
        rep(i, 1<<M) if(i!=j) cout << i << ' ';
        cout << j << ' ';
        rep(i, 1<<M) if((1<<M)-1-i!=j) cout << (1<<M)-1-i << ' ';
        cout << j << ' ';
        cout << "\n";
        return 0;
      }
    }
    cout << -1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n;i++){
        cin >> A[i];
    }
    vector<int> B(n);
    B=A;
    sort(B.begin(),B.end(),greater<int>());

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


}

Measured memory_bytes: 3200
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	q := getNextInt(scanner)
	f := NewFenwickTree64(n)
	for i := 0; i < n; i++ {
		f.Add(i, getNextInt64(scanner))
	}
	for q > 0 {
		q--
		t := getNextInt(scanner)
		if t == 0 {
			f.Add(getNextInt(scanner), getNextInt64(scanner))
			continue
		}
		fmt.Fprintln(writer, f.Sum(getNextInt(scanner), getNextInt(scanner)))
	}
}

// FenwickTree Data structure that can efficiently update elements and calculate prefix sums in a table of numbers.
type FenwickTree struct {
	tree *FenwickTree64
}

// NewFenwickTree Constructor
func NewFenwickTree(n int) *FenwickTree {
	return &FenwickTree{tree: NewFenwickTree64(n)}
}

// Add processes a[p] += x.
func (f *FenwickTree) Add(p int, x int) {
	f.tree.Add(p, int64(x))
}

// Sum returns a[l] + a[l - 1] + ... + a[r - 1].
func (f *FenwickTree) Sum(l, r int) int {
	return int(f.tree.Sum(l, r))
}

// FenwickTree64 Data structure that can efficiently update elements and calculate prefix sums in a table of numbers.
type FenwickTree64 struct {
	n    int
	data []int64
}

// NewFenwickTree64 Constructor
func NewFenwickTree64(n int) *FenwickTree64 {
	data := make([]int64, n+1)
	return &FenwickTree64{n: n, data: data}
}

// Add processes a[p] += x.
func (f *FenwickTree64) Add(p int, x int64) {
	for p++; p <= f.n; p += p & -p {
		f.data[p] += x
	}
}

// Sum returns a[l] + a[l - 1] + ... + a[r - 1].
func (f *FenwickTree64) Sum(l, r int) int64 {
	return f.sum(r) - f.sum(l)
}
func (f *FenwickTree64) sum(r int) int64 {
	s := int64(0)
	for ; r > 0; r -= r & -r {
		s += f.data[r]
	}
	return s
}


Measured memory_bytes: 15096
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int e[26];
    memset(e, 0, sizeof(e));
    for (char c : s) {
        e[c-'a'] ++;
    }
    for (int i = 0; i < 26; i++) {
        if (e[i] & 1) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7  ;
#define ld long double
#define MAX (int)(pow(10,5)+ 10)




void deal(){
	ll h , w;
	cin>>h>>w;
	vector<vector<ll> > dp(h+1, vector<ll> (w+1, 0));
	dp[0][1] = 1;
	vector<vector<char> > arr(h+1, vector<char> (w+1));
	fori(h)
		forj(w)
			cin>>arr[i+1][j+1];
	for(ll i =1; i<=h; i++)
		for(ll j = 1; j<=w; j++){
			if(arr[i][j] == '#')
				continue;
			dp[i][j] = (dp[i-1][j] + dp[i][j-1])%modulo;
		}
	cout<<dp[h][w];
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
/*
 
5 1
1 2 3 4 5


*/

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

int main(){
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  int a,b,ab;
  
  long ans=A*X+B*Y;
  for(int i=0; i<=2*max(X,Y); i++){
    a=X-(max(X,Y)==X?i/2:X-i/2>=0?i/2:X);
    b=Y-(max(X,Y)==Y?i/2:Y-i/2>=0?i/2:Y);
    
    if(ans>A*a+B*b+C*i){
      ans=A*a+B*b+C*i;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

main(){
	int x,y,w,h;
	int t;
	cin>>t;
	while(t--){
		cin>>x>>y>>w>>h;
		
		int n,ans=0;
		cin>>n;
		while(n--){
			int cx,cy;
			cin>>cx>>cy;
			if(x<=cx && cx<=x+w && y<=cy && cy<=y+h)++ans;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

void solve()
{
	vector<int> Num(5);
	for(int i = 0; i < 5; ++i)
	{
		cin >> Num[i];
	}
	sort(Num.begin(), Num.end(), greater<int>() );
	for(int i = 0; i < 5; ++i)
	{
		if(i == 4)
		{
			cout << Num[i];
		}
		else
		{
			cout << Num[i] << " ";
		}
	}
	cout << endl;
}

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

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

int main(){
    int n,m; cin >> n >> m;
    vector<bool> hole(n+1,true);
    for(int i=0;i<m;i++){
      int a; cin >> a;
      hole.at(a) = false;
    }

    vector<ll> dp(n+1,0);
    dp.at(0) = 1;

    for(int i=1;i<=n;i++){
      if(i==1){
        if(hole.at(i)) dp.at(i)=1;
      }else{
        if(hole.at(i)){
          dp[i]=(dp[i-1]+dp[i-2])%MOD;
        }else{
          dp[i]=0;
        }
      }
    }

    cout << dp.at(n) << endl;

    return 0;

}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int n,ans;
vector<int>v;
void func(){
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			if(i*i==n)v.push_back(i);
			else{
				v.push_back(i);
				v.push_back(n/i);
			}
		}
	}
}
signed main(){
	cin>>n;
	func();
	for(int x:v){
		int m=n/x-1;
		if(m>x)ans+=m;
	}
	cout<<ans<<endl;
	return 0;
}


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



c = 1
b = [1]
while c!=0 and (len(a) != 0) :
    b = []
    c = 0
    for i in enumerate(a):
        if not (i[0]+1 < i[1]):
            b.append(i[1])
        else:
            c = 1
    a = b
 
#print(a)
if len(a)==0:
    print(-1)
else:
    a = sorted(list(set(a)))
    b = []
    for i in enumerate(a):
        if i[0]+1 == i[1]:
            b.append(i[1])
    print(N-len(b))

Measured memory_bytes: 106616
#include <cmath>
#include <cstdio>
#include <deque>
#include <vector>

using namespace std;

template <typename T,
          template <typename V, typename = std::allocator<V>> class U>
void p(const U<T>& v)
{
    for (size_t i = 0; i < v.size() - 1; ++i) {
        printf("%d ", v[i]);
    }
    printf("%d\n", v[v.size() - 1]);
}

int insertionSort(vector<int>& v, int g, int cnt)
{
    for (size_t i = g; i < v.size(); ++i) {
        int e = v[i];
        int j = i - g;
        while (j >= 0 && v[j] > e) {
            v[j + g] = v[j];
            j = j - g;
            ++cnt;
        }
        v[j + g] = e;
    }
    return cnt;
}

int main()
{
    int N;
    scanf("%d", &N);
    vector<int> v;
    int t;
    for (int i = 0; i < N; ++i) {
        scanf("%d", &t);
        v.push_back(t);
    }
    int cnt = 0;

    deque<int> g = {1};
    auto lim = static_cast<int>(ceil(v.size() / 3.0));
    auto e = [](int n) { return 3 * n + 1; };
    while (true) {
        auto r = e(g[0]);
        if (r > lim) {
            break;
        }
        g.push_front(r);
    }

    for (size_t i = 0; i < g.size(); ++i) {
        cnt = insertionSort(v, g[i], cnt);
    }
    printf("%ld\n", g.size());
    p(g);
    printf("%d\n", cnt);
    for (auto&& i : v) {
        printf("%d\n", i);
    }
}

Measured memory_bytes: 6552
#include<bits/stdc++.h>
#define REP(n)    for(int i = 0; i < (n); ++i)
#define RREP(n)   for(int i = (n); i >= 0; --i)
#define FOR(m, n) for(int i = (m); i < (n); ++i)
#define SZ(x)       ( (int)(x).size() )
#define BIT(n)      ( 1LL << (n) )
#define EXIST(x)    ( (x).find()		!= (x).end() )
#define DEBUG(n)    cerr << #n << " : " << n << '\n';
#define PB  push_back
#define UB  upper_bound			//k <
#define LB  lower_bound			//k	<= 
#define F   first
#define S   second
#define INF 1.0e9


using namespace std;

typedef long long			ll;
typedef pair<int, int>		pii;
typedef pair<long			long, long long>   pll;
typedef vector<int>			vi;
typedef vector<double>		vd;
typedef vector<long long>   vll
;

template<class T> void chmax(T &	a, const T & b){ if( a < b ) a = b; }
template<class T> void chmin(T &	a, const T & b){ if( a > b ) a = b; }

int r_up(const int a, const int b){ return (a + b - 1) / b; }

const int dx[] = { 0,  0, 1, -1 };
const int dy[] = { 1, -1, 0,  0 };

struct UFT{
  vi	p;
  UFT(){}
  UFT(int N)       { p.resize( N, -1 ); }
  int	par(int a)   { if( p[a] >= 0 ){ p[a]  = par( p[a] ); return p[a]; } return a;  }
  int size(int a)  { return -p[par(a)]; }
  bool	same(int a, int b) { return par(a)	 == par(b); }
  void unite(int	a, int b){
	a													  = par(a);  b = par(b);
	if( a == b ) return;
	if( size(a) < size(b) ) swap(a,b);
	p[a]												 -= size(b);
	p[b]												  = a;
  }
};

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define alpha_size 26

const int N = 1e4 + 10;
int a[N];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    

    cout << fixed;
    cout << setprecision(20) << endl;
    double rad;
    cin >> rad;
    double res = 2 * M_PI * rad;
    cout << res << endl;
}



Measured memory_bytes: 3804
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> // added for pbds
#include<ext/pb_ds/tree_policy.hpp> // added for pbds
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forz(i,n) for(ll i = 0 ; i < n ;i++)
#define foro(i,n) for(ll i = 1; i<= n;i++)
#define fort(i,s,e) for(ll i = s ; i<e; i++)
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vll vector<pair<ll,ll> >
#define endll '\n'
#define space " "
#define INF 1000000000
#define ps(x,y) fixed<<setprecision(y)<< x; // to set precision to number x upto y decimal digits
#define D(x) cout << #x " = " << (x) << endl
//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction
using namespace std;
using namespace __gnu_pbds;// for pbds
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
//----------------------------------------------//
int t;
int main(){
    IOS
    int n;
    cin>>n;
    int a[n];
    int tot =0;
    for(int i=0 ;i < n;i++ )
        cin>>a[i],tot ^=a[i];
    for(int i=0;i<n;i++ ) {
        cout<< (a[i]^tot)<<endll;
    }
}






















Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
int main() {
    int n, W;
    cin >> n >> W;
    vector<ll> w(n),v(n);
    vector<vector<ll>> dp(n+1, vector<ll>(W+1,0));
    rep(i,n) cin >> w.at(i) >> v.at(i);
    rep(i,n){
        rep(j,W+1){
            if(j < w.at(i)) dp.at(i+1).at(j) = dp.at(i).at(j);
            else dp.at(i+1).at(j) = max(dp.at(i).at(j), dp.at(i).at(j-w.at(i))+v.at(i));
        }
    }
    cout << dp.at(n).at(W) << endl;
}

Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, q, a, b, p, x;
vector<int> vec[200010];
int cnt[200010];
int oy[200010];

void dfs(int n) {
	cnt[n] += cnt[oy[n]];
	for (int i = 0; i < vec[n].size(); i++) {
		if (vec[n][i] != oy[n]) {
			oy[vec[n][i]] = n;
			dfs(vec[n][i]);
		}
	}
	return;
}

signed main() {
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	for (int i = 0; i < q; i++) {
		cin >> p >> x;
		cnt[p] += x;
	}
	oy[1] = 0;
	dfs(1);
	for (int i = 1; i <= n; i++) {
		if (i != n)cout<< cnt[i] << " ";
		else cout << cnt[i] << endl;
	}
}

Measured memory_bytes: 25856
import java.util.Scanner;

public class Main {

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

		char three = s.charAt(2);
		char four = s.charAt(3);
		char five = s.charAt(4);
		char six = s.charAt(5);

		boolean answer = false;
		if (three == four && five == six) {
			answer = true;
		}

		printBool(answer);
	}

	public static void printBool(boolean bool) {
		print(bool ? "Yes" : "No");
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

int main()
{
	int n;
	int p[200000];
	cin >> n;
	rep(i, n) cin >> p[i];

	int count = 0;
	int min_val = INF;
	for (int i = 0; i < n; i++) {
		min_val = min(min_val, p[i]);
		if (min_val == p[i]) count++;
	}
	cout << count << endl;
}

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

const int N = 2e5 + 5;
char a[N];
int main() {
    int n; scanf("%d", &n);
    scanf("%s", a + 1);
    int len = strlen(a + 1);
    for(int i = 1;  i <= len; i++) {
        int tmp = a[i] - 'A';
        tmp = (tmp + n) % 26;
        a[i] = tmp + 'A';
    }
    printf("%s", a + 1);return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <string.h>
#define ll long long
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)

using namespace std;

const int MAXN = 1e5;

int n, arr[MAXN + 5];
int cnt[MAXN + 5], cnt2[MAXN + 5];

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> arr[i];
	int maks1 = 0, maks2 = 0, maks12 = 0, maks22 = 0, num1 = 0, num2 = 0;
	for(int i = 1; i <= n; i ++){
		if(i % 2){
			cnt[arr[i]]++;
		}else {
			cnt2[arr[i]]++;
		}
	}
	for(int i = 1; i <= 1e5; i ++){
		int tmp1 = maks1, tmp2 = maks2;
		if(maks2 < cnt2[i]){
			maks2 = cnt2[i];
			num2 = i;
			maks22 = tmp2;
		}else if(maks22 < cnt2[i])
		maks22 = cnt2[i];
	}
	for(int i = 1; i <= 1e5; i ++){
		int tmp1 = maks1, tmp2 = maks2;
		if(maks1 < cnt[i]){
			maks1 = cnt[i];
			num1 = i;
			maks12 = tmp1;
		}else if(maks12 < cnt[i])
		maks12 = cnt[i];
	}
	// cout << maks1 << ' ' << maks2 << ' ' << num1 << ' ' << num2 << endl;
	// cout << maks12 << ' ' << maks22 << endl;
	int fi = n/2, se = n/2;
	if(num1 == num2){
		if(maks22 < maks12){
			fi -= maks12;
			se -= maks2;
		}else{
			fi -= maks1;
			se -= maks22;
		}
	}else{
		fi -= maks1;
		se -= maks2;
	}
	cout << fi + se << endl;

	return 0;
}

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

using namespace std;
string s[510];
int a[510] = {};
int main(){
	int i,j,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> s[i];
	}
	int x = 0;
	for(j=0;j<n;j++){
		int cnt = 0;
		for(i=0;i<n;i++){
			if(s[i][j]=='#') cnt++;
		}
		if(cnt>=1) a[j] = 1;
		if(cnt==n) x++;
	}
	for(i=0;i<n;i++){
		if(a[i]==1) break;
		if(i==n - 1){
			cout << -1 << endl;
			return 0;
		}
	}
	int ans = 1000;
	for(i=0;i<n;i++){
		int c = 0;
		for(j=0;j<n;j++){
			if(s[i][j]=='.') c++;
		}
		if(a[i]==1) ans = min(ans,n - x + c);
		else ans = min(ans,n - x + c + 1);
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
  int N,M,i,j,K[30],A[30]={},i_A,ans=0;
  scanf("%d %d",&N,&M);
  for(i=0;i<N;i++)
  {
    scanf("%d",&K[i]);
    for(j=0;j<K[i];j++)
    {
      scanf(" %d",&i_A);
      A[i_A-1]++;
    }
  }
  for(i=0;i<M;i++)
  {
//    printf("%d ",A[i]);
    if(A[i]==N)
    {
      ans++;
    }
  }
//  printf("\n");
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>
#define upd(x, y) (x) = std::min(x, y)
int lst[1005], to[1005], pre[1005], tot; 
int dp[1005][10005], tmp[10005], sum[1005], mn[1005]; 
inline void add_edge(int u, int v)
{
	to[tot] = v;
	pre[tot] = lst[u]; 
	lst[u] = tot++; 
}
void dfs(int u)
{
	dp[u][0] = 0; 
	for (int i = lst[u]; ~i; i = pre[i])
	{
		dfs(to[i]); 
		memset(tmp, 0x3f, sizeof(tmp)); 
		for (int j = 0; j <= sum[u]; j++)
		{
			upd(tmp[j + sum[to[i]]], dp[u][j] + mn[to[i]]); 
			if (mn[to[i]] < 1e9)
				upd(tmp[j + mn[to[i]]], dp[u][j] + sum[to[i]]); 
		}
		memcpy(dp[u], tmp, sizeof(tmp)); 
	}
	mn[u] = 1e9; 
	for (int i = 0; i <= sum[u]; i++)
		upd(mn[u], dp[u][i]); 
}
int main()
{
	// freopen("ARC083-E.in", "r", stdin); 
	memset(lst, -1, sizeof(lst)); 
	memset(dp, 0x3f, sizeof(dp)); 
	int n; 
	scanf("%d", &n); 
	for (int i = 1; i < n; i++)
	{
		int x; 
		scanf("%d", &x); 
		add_edge(--x, i); 
	}
	for (int i = 0; i < n; i++)
		scanf("%d", sum + i); 
	dfs(0); 
	puts(mn[0] < 1e9 ? "POSSIBLE" : "IMPOSSIBLE"); 
	return 0; 
}


Measured memory_bytes: 39552
#include<bits/stdc++.h>
using namespace std;
int a[107],b[107];
int main(){
	int n,k;
	int ans=0;
	cin>>n>>k;
	for(int i=1;i<=n;++i)
        cin>>a[i];
	for(int i=1;i<=k&&i<=n;++i){
		for(int j=0;j<=i;++j){
			int l=j,r=i-j,cnt=0,res=0;
			for(int p=1;p<=l;++p)
                b[++cnt]=a[p];
			for(int p=n;p>n-i+j;--p)
                b[++cnt]=a[p];
			sort(b+1,b+cnt+1);
			for(int p=1;p<=k-i&&p<=cnt;++p)
                if(b[p]>=0)
                    break;
                else
                    b[p]=0;
			for(int p=1;p<=cnt;++p)
                res+=b[p];
			ans=max(ans,res);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
n=int(input())
s=list(input().strip())
i=0;j=n-1
an=0
while i<j:
  if s[i]=='W' and s[j]=='R':
    s[i]='R';s[j]='W'
    i+=1;j-=1
    an+=1;continue
  if s[i]=='R':
    i+=1
  if s[j]=='W':
    j-=1
print(an)

Measured memory_bytes: 10780
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		int ma[][]=new int[3][10];
		int mb[][]=new int[3][10];
		int mc[][]=new int[3][10];
		int md[][]=new int[3][10];
		for(int i=0;i<3;i++){
			for(int j=0;j<10;j++){
				ma[i][j]=0;
				mb[i][j]=0;
				mc[i][j]=0;
				md[i][j]=0;
			}
		}
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			int b=sc.nextInt();
			int f=sc.nextInt();
			int r=sc.nextInt();
			int v=sc.nextInt();
			switch(b){
			case 1:
				ma[f-1][r-1]+=v;
				break;
			case 2:
				mb[f-1][r-1]+=v;
				break;
			case 3:
				mc[f-1][r-1]+=v;
				break;
			case 4:
				md[f-1][r-1]+=v;
				break;
			}
		}
		for(int i=0;i<3;i++){
			for(int j=0;j<10;j++){
				System.out.print(" "+ma[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for(int i=0;i<3;i++){
			for(int j=0;j<10;j++){
				System.out.print(" "+mb[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for(int i=0;i<3;i++){
			for(int j=0;j<10;j++){
				System.out.print(" "+mc[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for(int i=0;i<3;i++){
			for(int j=0;j<10;j++){
				System.out.print(" "+md[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 29152
import java.util.Scanner;

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

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		int count = 0;

		for(int i=0;i+a<=b;i++){
			if(c%(a+i) == 0){
				count++;
			}
		}

		System.out.println(count);

		scan.close();
	}
}

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

int main()
{

        int H, W;
        cin >> H >> W;
        int N;
        cin >> N;
        int a[N];
        for (int i = 0; i < N; ++i) {
                cin >> a[i];
        }

        int t = 0;
        int res[H][W];
        for (int i = 0; i < H; ++i) {

                if (i % 2 == 0) {

                        for (int j = 0; j < W; ++j) {
                                if (a[t] == 0) {
                                        t++;
                                }
                                res[i][j] = t + 1;
                                a[t]--;
                        }

                }
                else {

                        for (int j = W - 1; j > -1; --j) {

                                if (a[t] == 0) {
                                        t++;
                                }
                                res[i][j] = t + 1;
                                a[t]--;

                        }
                }

                for (int j = 0; j < W; ++j) {

                        cout << res[i][j] << " ";

                }
                cout << endl;

        }






}


Measured memory_bytes: 384
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var result = true;
            for (int i = N - 1; i > 0; i--)
            {
                if (H[i] + 1 < H[i - 1])
                {
                    result = false;
                    break;
                }
                else if (H[i] + 1 == H[i - 1])
                {
                    H[i - 1]--;
                }
            }
            Console.WriteLine(result ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 30172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> A(N);
  ll tmp = 0;
  rep(i, N) {
    cin >> A[i];
    tmp ^= A[i];
  }
  rep(i, N) {
    cout << (tmp ^ A[i]) << ' ';
  }
  cout << endl;
  return 0;
}


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

int main() {
    int n;
    int x[101], y[101], h[101];

    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d%d%d", &x[i], &y[i], &h[i]);

    for (int cx = 0; cx < 101; cx++) {
        for (int cy = 0; cy < 101; cy++) {
            int H_max = 2000000000;
            int H_cand = -1;
            int i = 0;
            for (; i < n; i++) {
                int dist = abs(x[i]-cx) + abs(y[i]-cy);
                if (h[i] == 0) {
                    H_max = min(H_max, dist);
                } else {
                    if (H_cand == -1) {
                        H_cand = dist + h[i];
                    } else if (H_cand != dist + h[i]) {
                        break;
                    }
                }
            }

            if (i == n && H_cand <= H_max && H_cand > 0) {
                printf("%d %d %d\n", cx, cy, H_cand);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128