akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(auto i=0;i<n;i++)

struct Node{
	int id;
	int depth;
	Node *parent;
	vector<Node*> childs;

    bool operator<( const Node& param ) const {
        return id < param.id;
    }
};
Node *nil;
list<int> ids;
map<int, list<int>> getChilds;
vector<Node> vectored;

void flat(Node* node){
	vectored.push_back(*node);
	for(Node* tmp : node->childs){
		flat(tmp);
	}
}

void conChilds(Node *node){
	for(int childId : getChilds[node->id]){
		Node *child = new Node();
		child->id = childId;
		child->depth = node->depth + 1;
		child->parent = node;
		(node->childs).push_back(child);
		conChilds(child);
	}
}

int main(){
	int n, id, k, t, maxId = 100000;
	cin >> n;

	r(i, n){
		cin >> id >> k;
		ids.push_back(id);
		list<int> childs;
		maxId = max(maxId, id);
		r(j, k){
			cin >> t;
			childs.push_back(t);
		}
		getChilds[id] = childs;
	}

	//search root
	bool isRoot[maxId+1]{};
	for(int id : ids){
		isRoot[id] = true;
	}
	for(int id : ids){
		for(int childId : getChilds[id]){
			isRoot[childId] = false;
		}
	}

	int rootId = -1;
	r(i, maxId+1){
		if(isRoot[i]){
			rootId = i;
			break;
		}
	}

	if(rootId == -1)
		printf("root couldn't be found");

	Node *root = new Node();
	root->id = rootId;
	root->depth = 0;
	root->parent = nil;

	conChilds(root);

	flat(root);
	sort(vectored.begin(), vectored.end());

	for(Node node : vectored){
		cout << "node " << node.id << ": ";
		cout << "parent = " << (node.parent == nil ? -1 : node.parent->id) << ", ";
		cout << "depth = " << node.depth << ", ";
		k = node.childs.size();
		if(node.parent == nil){
			cout << "root";
		}else if(k == 0){
			cout << "leaf";
		}else{
			cout << "internal node";
		}
		cout << ", [";
		if(k > 0){
			cout << node.childs[0]->id;
			for(int i = 1; i < k; i++){
				cout << ", " << node.childs[i]->id;
			}
		}
		cout << "]" << endl;
	}

	return 0;
}


Measured memory_bytes: 27448
#include <stdio.h>

int isprime(int x){
  if(!(x&1)) return 0;
  
  int i;
  for(i=3;i*i<x;i+=2){
    if(!(x%i)) return 0;
  }
  return 1;
}

int main(){
  int n;
  while(scanf("%d", &n)!=EOF){
    int i;

    int bottom=2;
    for(i=n-1;i>=2;i--) if(isprime(i)) bottom = i,i=0;

    int upper=0;
    for(i=n+1;i<=60000;i++) if(isprime(i)) upper=i,i=70000;

    printf("%d %d\n", bottom, upper);
  }
}

Measured memory_bytes: 0
import java.io.*;
  
class Main{
    public static void main(String[] args) throws Exception{
        int x, ans;
      
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        x = Integer.parseInt(br.readLine());
          
        ans = x*x*x;
        System.out.println(ans);
    }
}

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

using namespace std;

int main()
{
  int k;
  cin >> k;
  vector<long long> a(k);
  for (int i = 0; i < k; i++)
    cin >> a[i];
  long long l = 2, r = 2;
  for (int i = k - 1; - 1 < i; i--)
  {
    l = (l + a[i] - 1) / a[i] * a[i];
    r = r / a[i] * a[i] + a[i] - 1;
  }
  if (r < l)
    cout << -1 << endl;
  else
    cout << l << " " << r << endl;

  return 0;
}


Measured memory_bytes: 1024
#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){
  while(x->left!=NIL){
    x=x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x=x->right;
  }
  return x;

}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if(k < u->key){
   return treeSearch(u->left,k);
  }
  else {
    return treeSearch(u->right,k);
  }

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL){
    return treeMinimum(x->right);
  }
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  
  if(z->left==NIL || z->right==NIL){
    y=z;
  }
  else{
    y= treeSuccessor(z);
  }
  
  if(y->left!=NIL){
    x=y->left;
  }
  else{
    x=y->right;
  }
  
  if(x!=NIL){
    x->parent=y->parent;
  }
  
  if(y->parent==NIL){
    root=x;
  }
  else if(y==y->parent->left){
    y->parent->left=x;
  }
  else {
    y->parent->right=x;
  }
  
  if(y!=z){
    z->key=y->key;
  }
}

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);
  }
}

Node find(Node u, int k ){
  while(u!=NIL && k!=u->key ){
    if(k<u->key ){
      u = u->left;
    }
    else{
      u = u->right;
    }
  }
  return u;
}

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: 19360
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;

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

int main()
{
    int h,w;cin>>h>>w;
    int m[h][w];
    int black=0;
    REP(i,h)
    {
        string s;cin>>s;
        REP(j,w)
        {
            if(s[j]=='#'){m[i][j]=-1;black++;}
            else m[i][j]=0;
        }
    }
    queue<pair<int,int>>q;q.push(make_pair(0,0));
    m[0][0]=1;
    while(!q.empty())
    {
        int x=q.front().first;int y=q.front().second;
        if(x==w-1&&y==h-1)break;
        q.pop();
        REP(i,4)
        {
            if(y+dy[i]<0||y+dy[i]>=h||x+dx[i]<0||x+dx[i]>=w)continue;
            if(m[y+dy[i]][x+dx[i]]==0)
            {
                m[y+dy[i]][x+dx[i]]=m[y][x]+1;
                q.push(make_pair(x+dx[i],y+dy[i]));
            }
        }
    }
    if(m[h - 1][w - 1] == 0)cout<<-1<<endl;
    else cout<<h*w-m[h-1][w-1]-black<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <atcoder/all>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, Q;

constexpr ll mod = 998244353;

using T = ll;
using Pr = std::pair<T, ll>;

ll ten[200010];

Pr op( Pr a, Pr b ) {
  return Pr( (a.first*ten[b.second]%mod+b.first+mod)%mod, a.second+b.second );
}

Pr e() {
  return Pr( 0, 0 );
}

ll po[10][200010];

Pr mapping( T f, Pr x ) {
  if( f == -INF )
    return x;

  return Pr( po[f][x.second], x.second );
}

T composition( T x, T y ) {
  if( x == -INF )
    return y;
  
  return x;
}

T id() {
  return -INF;
}

ll L[200010], R[200010], D[200010];

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

  ten[0] = 1;

  rep( i, N+5 )
    ten[i+1] = ten[i]*10%mod;

  rep( d, 10 ) {
    po[d][0] = 0;
    po[d][1] = d;

    rep( i, N+5 )
      po[d][i+1] = (po[d][i]*10+d)%mod;
  }

  atcoder::lazy_segtree<Pr, op, e, T, mapping, composition, id> seg( N+10 );

  rep( i, N )
    seg.set( i, P( 1, 1 ) );

  rep( q, Q ) {
    std::cin >> L[q] >> R[q] >> D[q];
    --L[q];

    seg.apply( L[q], R[q], D[q] );

    std::cout << seg.all_prod().first << endl;
  }

  return 0;
}

Measured memory_bytes: 35332
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
const long long MOD = 1000000007;
 
 
void solve(int N, std::vector<int> A){
    map<int,int> list;
    
    bool error = false;
    REP(i, N){
            list[A[i]]++;
    }
    if(N%2==0){ //even
        for(int i=1; i<N; i+=2) if(list[i]!=2){error=true;break;}
    }
    else{ //odd
        for(int i=2; i<N; i+=2)if(list[i]!=2){error=true;break;}
        if(list[0]!=1)error=true;
        
    }    
    if(error){
        cout<<0<<endl;
        return;
    }
    LL ans=1;
    REP(i,N/2){
      ans*=2;
      ans%=MOD;
    }
    cout<<ans<<endl;
    return;
}
 
int main(){
    int N;
    cin>>N;
    std::vector<int> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%d",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}

Measured memory_bytes: 3584
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {

	
	
	public static void main(String[] args) {
		int n = in.nextInt();
		int m = in.nextInt();
		
		System.out.println(n*(n-1)/2+m*(m-1)/2);
		
		out.flush();
		out.close();
		
	}
	
	

	//NONPROBLEM CODE
	
	private static InputReader in = new InputReader(System.in);
	private static PrintWriter out = new PrintWriter(System.out);
	
	private static class InputReader {
		 
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
 
		public InputReader(InputStream st) {
			this.stream = st;
		}
 
		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
 
		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
 
		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
 
		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
 
		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}
 
		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}
 
		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
 
		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
 
	}
	
	private static void debug(Object... o) {
		for(Object x: o) {
			out.write(x+" ");
		}
		out.write("\n");
		out.flush();
	}
	
}


Measured memory_bytes: 22612
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

long long lcm(long long a, long long b)
{
	return a * b / gcd(a, b);
}

// 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; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int countA = (a % d == 0) ? a / d : a / d + 1;
	int countB = (c % b == 0) ? c / b : c / b + 1;
	cout << (countA >= countB ? "Yes" : "No");
}



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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
aN = LIST()
avg = sum(aN) / len(aN)
aN2 = [[0] * 2 for i in range(N)]
for i in range(N):
    aN2[i][0] = i
    aN2[i][1] = abs(aN[i] - avg)

aN2.sort(key=itemgetter(1))
print(aN2[0][0])


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

int main(){
	int a,b,c;
  	cin >> a >> b >> c;
  	
  	if(a != b && b != c && a != c){
    	cout << "No" << endl;
    }else if(a == b && b == c && a == c){
    	cout << "No" << endl;
    }else{
    	cout << "Yes" << endl;
    }
}

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 1e5 + 41;

int par[MAX];
int size[MAX];

int x[MAX];
int y[MAX];

int n, m;

int find(int x) {
	if (par[x] == x) return x;
	return par[x] = find(par[x]);
}

bool uni(int a, int b) {
	a = find(a);
	b = find(b);
	if (a == b) return false;
	size[a] += size[b];
	par[b] = a;
	return 1;
}

void solve() {
	fi(1, n) {
		par[i] = i;
		size[i] = 1;
	}
	
	fi(1, m) {
		uni(x[i], y[i]);
	}

	ll all = (ll) n * (n - 1) / 2;
	all -= m;

	int c1 = size[find(1)];
	int c2 = size[find(2)];
	int c3 = n - c1 - c2;

	if (c1 > c2) {
		swap(c1, c2);
	}

	c2 += c3;

	all -= (ll) c1 * c2;
	printf("%lld\n", all);
}

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

  scanf("%d %d", &n, &m);
  fi(1, m) {
  	scanf("%d %d", &x[i], &y[i]);
  }
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

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

vector<vector<int>> g;
vector<bool> used;

void dfs(int v) {
  if (used[v]) return;
  used[v] = true;
  for (int u : g[v])
    dfs(u);
}

int main() {
#ifdef LOCAL
  freopen("d.in", "r", stdin);
  freopen("d.out", "w", stdout);
#endif

  int n;
  while (scanf("%d", &n) == 1) {
    vector<int> a = get_input(n);
    vector<int> b = get_input(n);
    n += 1;

    vector<int> as = a, bs = b;
    sort(as.begin(), as.end());
    sort(bs.begin(), bs.end());
    if (as != bs) {
      printf("-1\n");
      continue;
    }

    as.erase(unique(as.begin(), as.end()), as.end());
    for (int &x : a) {
      x = (int) (lower_bound(as.begin(), as.end(), x) - as.begin());
    }
    for (int &x : b) {
      x = (int) (lower_bound(as.begin(), as.end(), x) - as.begin());
    }

    g = vector<vector<int>>(as.size());
    used = vector<bool>(as.size());

    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
        ans++;
      }
    }

    for (int i = 0; i < (int)as.size(); i++) {
      if (used[i]) continue;
      if (g[i].empty()) continue;
      ans++;
      dfs(i);
    }

    if (!g[a[n-1]].empty()) {
      ans -= 2;
      if (a[n-1] == b[n-1]) {
        ans += 1;
      }
    }


    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 10368
St2=[[1],[0,1]]
2.upto(1000){|n|St2<<[0,*St2[-1].each_cons(2).map.with_index(1){|(x,y),k|x+y*k},1]}
a,b=gets.split.map &:to_i
p (1..b).reduce(:*)*St2[a][b].to_i%(10**9+7)


Measured memory_bytes: 241288
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a, b; cin >> a >> b;

    cout << a * b << endl;

    return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    int ans = 0;
    ans += N * (N - 1) / 2;
    ans += M * (M - 1) / 2;
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
using namespace std;
const int mod=924844033;
const int N=5011;
int n,k,tot,ans;
int f[N][N][2],fac[N];
bool vis[N][2];
int ed[N];
int main(){
	scanf("%d%d",&n,&k);
	f[1][0][0]=1;
	rep(i,1,n)
		rep(j,0,1)
			if(!vis[i][j]){
				for(register int x=i,y=j;x<=n;x+=k,y^=1)
					vis[x][y]=1,++tot;
				ed[tot]=1;
			}
	rep(i,1,tot)
		rep(j,0,n){
			f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%mod;
			if(!ed[i])f[i+1][j+1][1]=f[i][j][0];
		}
	fac[0]=1;
	rep(i,1,n)
		fac[i]=1ll*i*fac[i-1]%mod;
	rep(i,0,n){
		int s=i&1;
		if(s)s=-1;
		else s=1;
		ans=(ans+1ll*s*(f[tot][i][0]+f[tot][i][1])*fac[n-i]%mod)%mod;
		ans=(ans+mod)%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 156800
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	fmt.Println((scanInt() + 1) / 2)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[0] = scanInt()
	}
	return ints
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  cout << N * (N-1) / 2 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str):
    min_diff = float("inf")
    for i in range(len(S)-2):
        min_diff = min(min_diff,abs(753-int(S[i:i+3])))

    print(int(min_diff))
        

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: int
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
  double X;
  cin >> X;

  double Y = 100.0;

  long long counter = 0;
  while (Y < X) {
    Y *= 1.01;
    Y = floor(Y);
    counter++;
  }

  cout << counter << endl;
  return 0;
}
 


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, K;
ll H[int(1e5+5)], DP[int(1e5+5)];

int main(){
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> H[i];
  fill(DP, DP + N, 1e18);
  DP[0] = 0;
  for (int i = 0; i < N; i++){
    for (int j = 1; j <= K && i + j < N; j++){
      DP[i+j] = min(DP[i+j], DP[i] + abs(H[i] - H[i+j]));
    }
  }
  cout << DP[N-1] << endl;

  return 0;
}


Measured memory_bytes: 5128
#include<bits/stdc++.h>
#include <boost/algorithm/string.hpp>
using namespace std;
typedef long long int ll;
#define int ll
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i < (b); i++)
#define derep(i, a, b) for(long long i = (a); i>= (b) ; i--)
#define M 32
#define split(result, input, ch) boost::split((result), (input), boost::is_any_of((ch) ) );

int solve(string s, int index){
    // cout<<"the index is "<<index<<endl;
    if(index >= s.size()){
        int sum = 0;
        vector<string> result;
        split(result, s, "+");
        rep(i, 0, result.size()){
            stringstream wtf(result[i]);
            int x = 0;
            wtf >>x;
            sum += x;
        }
        // cout<<"returning sum "<<sum<<endl;
        return sum;
    }
    // cout<<s<<endl;
    int opt1 = 0, opt2 = 0;
    opt1 =  solve(s, index + 1);
    string str = s;
    string sub1 = str.substr(0, index);
    string sub2 = str.substr(index, str.size() - index);
    // cout<<"bifurcating at index "<<index<<endl;
    sub1 += "+";
    str = sub1 + sub2;
    // cout<<sub1<<endl;
    // cout<<sub2<<endl;
    opt2 = solve(str, index + 2);
    // cout<<"sending string "<<str<<endl;
    // cout<<"the index is "<<index<<" and the sum is "<<opt1 + opt2<<endl;
    return  opt2 + opt1;
}

int32_t main(){
  string s;
  cin>>s;
  cout<<solve(s, 1);
}


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

using namespace std;

int main(){
    int a, b, q; cin >> a >> b >> q;
    vector<long long> ss(a);
    vector<long long> ts(b);
    for(int i=0; i<a; ++i){
        cin >> ss[i];
    }
    for(int i=0; i<b; ++i){
        cin >> ts[i];
    }
    sort(ss.begin(), ss.end());
    sort(ts.begin(), ts.end());

    vector<long long> nearest_s(a);
    for(int i=0; i<a; ++i){
        auto p=lower_bound(ts.begin(), ts.end(), ss[i]);
        int idx=p-ts.begin();
        if(idx==0){
            nearest_s[i]=abs(ts[0]-ss[i]);
        } else if(idx>=b){
            nearest_s[i]=abs(ts[b-1]-ss[i]);
        } else{
            nearest_s[i]=min(abs(ts[idx-1]-ss[i]), abs(ts[idx]-ss[i]));
        }
    }

    vector<long long> nearest_t(b);
    for(int i=0; i<b; ++i){
        auto p=lower_bound(ss.begin(), ss.end(), ts[i]);
        int idx=p-ss.begin();
        if(idx==0){
            nearest_t[i]=abs(ss[0]-ts[i]);
        } else if(idx>=a){
            nearest_t[i]=abs(ss[a-1]-ts[i]);
        } else{
            nearest_t[i]=min(abs(ss[idx-1]-ts[i]), abs(ss[idx]-ts[i]));
        }
    }

    for(int i=0; i<q; ++i){
        long long x; cin >> x;
        long long ans_s, ans_t;
        {
            auto p_s=lower_bound(ss.begin(), ss.end(), x);
            int idx_s=p_s-ss.begin();
            if(idx_s==0){
                ans_s=abs(ss[0]-x)+nearest_s[0];
            } else if(idx_s>=a){
                ans_s=abs(ss[a-1]-x)+nearest_s[a-1];
            } else{
                ans_s=abs(ss[idx_s-1]-x)+nearest_s[idx_s-1];
                ans_s=min(ans_s, abs(ss[idx_s]-x)+nearest_s[idx_s]);
            }
        }
        {
            auto p_t=lower_bound(ts.begin(), ts.end(), x);
            int idx_t=p_t-ts.begin();
            if(idx_t==0){
                ans_t=abs(ts[0]-x)+nearest_t[0];
            } else if(idx_t>=b){
                ans_t=abs(ts[b-1]-x)+nearest_t[b-1];
            } else{
                ans_t=abs(ts[idx_t-1]-x)+nearest_t[idx_t-1];
                ans_t=min(ans_t, abs(ts[idx_t]-x)+nearest_t[idx_t]);
            }
        }
        cout << min(ans_s, ans_t) << endl;
    }
    return 0;
}


Measured memory_bytes: 4480
#include<stdio.h>
#include<iostream>
#include<set>
#include<string.h>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<string.h>

using namespace std;
  
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
 
#define pb push_back
#define ii pair<int, int>
#define vai freopen("in","r",stdin);
#define inf 0x3f3f3f3f
#define f first
#define s second

const ll INF = 1e18;
const double dinf = 12345678;
const int MOD = 1e9 + 7;
const int maxn = 1e5 + 10;
 


int ans = inf, n;
string str;

int main(){
	 
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	cin >> n;
	cin >> str;
	
	int r = 0 ,l = 0 ;
	int tr = 0, tl = 0;
	
	for(int i = 0 ;str[i];i++){
		if ( str[i] == 'E')++tr;
		else ++tl;
	}
	
	if ( !tr or !tl ) {
		ans = 0;
		cout << ans << '\n'; return 0;
	}
	
	for(int i = 0; str[i];i++){
		ans = min ( ans,l + (tr - (str[i]=='E') - r) );
		if(str[i] =='E' ){
			++r;
		}else{
			++l;
		}
		
	}
	
	cout << ans << '\n'; return 0;

 

}


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

int R=1,C=1,H[2000010]={0},N[2000010]={2100000000};

void hin(int a){
  int i=C++;
  for(N[R]=a;a>N[H[i/2]];i/=2)
  	H[i]=H[i/2];
  H[i]=R++;
}
int hout(){
  int rt=H[1],nt=1,i=0,k=H[--C];
  while(nt-i){
    H[i=nt]=k;
    if(i*2  <C&&N[  k  ]<N[H[i*2  ]])
		H[i]=H[nt=i*2  ];
    if(i*2+1<C&&N[H[nt]]<N[H[i*2+1]])
		H[i]=H[nt=i*2+1];
  }
  return rt;
}
int main(){
  int a;
  char s[1000];
  while(scanf("%s",s),s[2]-'d'){
    if(s[0]=='i'){
      scanf("%d",&a);
      hin(a);
    }
    else printf("%d\n",N[hout()]);
  }
  return 0;
}



Measured memory_bytes: 11568
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>

using namespace std;

int x[14] = {1,
  6 /*6^1*/ , 6 * 6 /*6^2 */, 6 * 6 * 6 /*6^3*/, 6 * 6 * 6 * 6 /*6^4*/, 6 * 6 * 6 * 6 * 6 /*6^5*/, 6 * 6 * 6 * 6 * 6 * 6 /*6^6*/, 6 * 6 * 6 * 6 * 6 * 6 * 6 /*6^7*/,
  9 /*9^1*/, 9 * 9 /*9^2*/, 9 * 9 * 9 /*9^3*/, 9 * 9 * 9 * 9 /*9^4*/, 9 * 9 * 9 * 9 * 9 /*9^5*/, 9 * 9 * 9 * 9 * 9 * 9/*9^6*/};
int dp[14][100001];
int main(){
  int N;
  cin >> N;
  dp[0][0] = 0;
  for(int i = 1; i <= N; i++){
    dp[0][i] = dp[0][i - 1] + 1;
  }
  for(int i = 1; i < 14; i++){
    for(int j = 0; j <= N; j++){
      dp[i][j] = dp[i - 1][j];
      if(j - x[i] >= 0){
        dp[i][j] = min(dp[i][j], dp[i][j - x[i]] + 1);
      }
    }
  }

  cout << dp[13][N] << endl;
  return 0;
}


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

#define ll long long int
#define pii pair<int,int>
#define PII pair<ll,ll>

const ll sz=1e5+100;
vector<ll> ad[sz];

int main()
{
    ll n,m,i,j,k,p,x,y;

    cin>>n>>m;
    for(i=0;i<n;i++) {
        cin>>x>>y;
        ad[x-1].push_back(y);
    }
    priority_queue<ll> pq;

    ll ans=0;
    for(i=m;i>=1;i--){
        ll siz=ad[m-i].size();
        for(j=0;j<siz;j++) pq.push(ad[m-i][j]);
        if(pq.size()==0) continue;
        ll x=pq.top();
        pq.pop();
        ans+=x;
    }

    cout<<ans<<'\n';
}


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

using namespace std;

using Edge = int;
using Edges = vector<Edge>;
using Graph = vector<Edges>;

Graph Compression(const int n, const int m, vector<set<int>> &g) {
    stack<int> st;
    for (int v = 0; v < n; ++v)
        if (g[v].size() == 1) st.push(v);

    while (!st.empty()) {
        int cur = st.top(), dst = *g[cur].begin();
        st.pop();
        g[cur].clear();
        g[dst].erase(cur);
        if (g[dst].size() == 1) st.push(dst);
    }

    for (int v = 0; v < n; ++v)
        if (g[v].size() == 2) st.push(v);

    while (!st.empty()) {
        int cur = st.top(); st.pop();

        if (g[cur].size() != 2) continue;
        int d1 = *g[cur].begin(), d2 = *g[cur].rbegin();

        if (d1 == d2 || g[d1].count(d2) != 0) continue;

        g[cur].clear();
        g[d1].erase(cur);
        g[d2].erase(cur);

        g[d1].insert(d2);
        g[d2].insert(d1);

        if (g[d1].size() == 2) st.push(d1);
        if (g[d2].size() == 2) st.push(d2);
    }

    map<int, int> idx_v;
    int size = 0;
    for (int v = 0; v < n; ++v)
        if (2 <= g[v].size()) idx_v[v] = size++;

    Graph h(size);
    for (int v = 0; v < n; ++v) {
        if (idx_v.count(v) == 0) continue;

        int cur = idx_v[v];
        for (int dst : g[v]) {
            if (idx_v.count(dst) == 0) continue;
            h[cur].emplace_back(idx_v[dst]);
        }
    }

    return h;
}

int Backtrack(const int s, const int nb, const int p, const int cur, vector<bool> &visited, const Graph &g) {
    int res = 0;

    for (auto dst : g[cur]) {
        if (dst == p || dst < s) continue;
        if (dst == s && nb <= cur)
            ++res;
        else if (!visited[dst]) {
            visited[dst] = true;
            res += Backtrack(s, nb, cur, dst, visited, g);
            visited[dst] = false;
        }
    }

    return res;
}

int CountingCycles(Graph g) {
    const int n = g.size();

    if (n <= 1) return 0;

    vector<bool> visited(n, false);
    int cnt = 0;
    for (int s = 0; s < n; ++s) {
        visited[s] = true;
        for (auto dst : g[s]) {
            if (dst < s) continue;
            visited[dst] = true;
            cnt += Backtrack(s, dst, s, dst, visited, g);
            visited[dst] = false;
        }
        visited[s] = false;
    }

    return cnt;
}


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

    int n, m, u, v;

    cin >> n >> m;
    vector<set<int>> g(n);
    for (int i = 0; i < m; ++i) {
        cin >> u >> v;
        g[u - 1].insert(v - 1);
        g[v - 1].insert(u - 1);
    }

    cout << CountingCycles(Compression(n, m, g)) << endl;

    return 0;
}



Measured memory_bytes: 17540
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pb push_back
#define ii pair<int, int>
#define MAXN int(1e6)
#define qi queue<int>
#define si stack<int>
#define mii map<int, int>
#define msi map<string, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
using namespace std;

int main(int argc, char** argv) {
	ios::sync_with_stdio(0);
	cin.tie(0);
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	string s, t, ans="";
	cin >> s >> t;
	int dp[s.length()+1][t.length()+1];

	for (int i = 0; i <= s.length(); i++) {
		for (int j = 0; j <= t.length(); j++) {
			if (i == 0 || j == 0)
				dp[i][j] = 0;
			else if (s[i-1] == t[j-1])
				dp[i][j] = dp[i-1][j-1]+1;
			else 
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			//cout << dp[i][j] << ' ';
		}
		//cout << '\n';
	}

	int index = dp[s.length()][t.length()];
	//char a[dp[s.length()][t.length()]];
	char a[index+1];
	a[index] = '\0';
	int i = s.length(), j = t.length();

	while (i > 0 && j > 0) {
		if (s[i-1] == t[j-1]) {
			a[index-1] = s[i-1];
			i--; j--; index--;
		}

		else if (dp[i-1][j] > dp[i][j-1])
			i--;
		else 
			j--;
	}

	//reverse(all(ans));
	//cout << ans << '\n';
	cout << a << '\n';
	return 0;
}






Measured memory_bytes: 35456
#include <iostream>
#include<vector>
using namespace std;
int main(){
    string s; string t; cin >> s >> t;
    size_t length = s.length();
    int ans = 0;
    for (int i; i < length; i++) {
        if (s[i] != t[i]) { ans++; }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3896
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long ull;
typedef long long ll;

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

using namespace std;

typedef pair<int ,int > P;

int n,m;
vector<int> vec;
int main()
{
	cin>>n;
	rep(i,n+1)
	{
		vec.pb(i);
	}

	cin>>m;

	rep(i,m)
	{
		int a,b;
		scanf("%d,%d",&a,&b);
		swap(vec[a],vec[b]);
	}
	rep(i,n+1)
	{
		if(!i) continue;
		cout<<vec[i]<<endl;
	}
	


	return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <random>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}

int main(){
    string s;
    ll n;
    ll sum1=0,sum2=0;
    cin >> n;
    
    vector<ll> a(n);
    rep(i, n) cin>>a[i];
    
    sort(alll(a));
    rep(i, n) i%2==0 ? sum1+=a[i]: sum2+=a[i];
    
    pr(abs(sum2-sum1));
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    ans=0
    for i in range(1,n-1):
        ans+=(A[i-1]<A[i]<A[i+1]) or (A[i-1]>A[i]>A[i+1])
    print(ans)
resolve()

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define PI 3.14159265359

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

    int cnt = 0;
    while(1){
        rep(i, n){
            if(a[i] % 2 == 0){
                a[i] /= 2;
            }else{
                cout << cnt << endl;
                return 0;
            }
        }
        cnt++;
    }

    return 0;
}


Measured memory_bytes: 3552
/* 
  In the name of ALLAH
  Author : Raashid Anwar
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define int    int64_t
const int M = 1000000007;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
  //#endif
  int x,ans=0;
  cin>>x;
  ans+=(x/500)*1000;
  x%=500;
  cout<<ans+((x/5)*5)<<"\n";
}

Measured memory_bytes: 256
n,m=map(int,input().split())

ab=[]
for i in range(n):
    ab.append(list(map(int,input().split())))

cd=[]
for j in range(m):
    cd.append(list(map(int,input().split())))

#print(ab)
#print(cd)

for i in range(len(ab)):
    number=0
    far=float("inf")
    for j in range(len(cd)):
        ans0=abs(ab[i][0]-cd[j][0])
        ans1=abs(ab[i][1]-cd[j][1])
        ans=ans0+ans1
        if far>ans:
            far=ans
            number=j+1
    print(number)


Measured memory_bytes: 3188
N = int(input())
import numpy as np
P = np.array(list(map(int,input().split())))
Q = np.array(list(map(int,input().split())))
l = [0]*N
l[0]=1
for i in range(2,N+1):
  l[i-1]=l[i-2]*i

a = 0
b=0
for i in range(N):
  p=P[0]
  P=P[1::]
  q=Q[0]
  Q=Q[1::]
  P[P>p]-=1
  Q[Q>q]-=1
  a += l[N-2]*(p-1)+1
  b += l[N-2]*(q-1)+1
  N-=1
  
a-=N-1
b-=N-1
print(abs(a-b))

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n;
	vector<ll> v(5, 0);
	ll mi = INF;

	cin >> n;

	REP(i, 5) {
		cin >> v[i];
		mi = min(mi, v[i]);
	}

	cout << (ll)ceil((double)n / (double)mi) + 4 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100


int main(){
  int n,A[N+1],k;
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(k=0;k<n;k++){
    if(k>0)printf(" ");
    printf("%d",A[k]);
  }
  printf("\n");

int j,v;
for(i=1;i<n;i++){
  v=A[i];
  j=i-1;
  while(j>=0 && A[j]>v){
    A[j+1]=A[j];
    j--;
    A[j+1]=v;
  }
  for(k=0;k<n;k++){
    if(k>0)printf(" ");
    printf("%d",A[k]);
  }
  printf("\n");
 }
return 0;
}



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

using namespace std;

int n;
int c[510], s[510], f[510];

int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> c[i] >> s[i] >> f[i];
  }

  for (int i = 0; i < n; i++) {
    int p = 0;
    for (int j = i; j < n - 1; j++) {
      if (p < s[j]) {
        p = s[j] + c[j];
      } else {
        int q = p - s[j];
        p = s[j] + (q + f[j] - 1) / f[j] * f[j] + c[j];
      }
    }
    cout << p << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n, m = map(int, input().split())
d = m
r = d + 1
for i in range(m):
    if d <= 0:
        break
    a = i + 1
    b = a + d
    print(a, b)
    d -= 2
d = m - 1
for i in range(m):
    if d <= 0:
        break
    a = r + i + 1
    b = a + d
    print(a, b)
    d -= 2


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) begin(v), end(v)
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,b) FOR(i,0,b)

const ll mod = 1e9+7;
ll INF = 1000;

string o[]={"maerd","remaerd","esare","resare"};
string s,s2;
ll x;
int main(){
  cin>>s;

  for(int i=s.size()-1;i>=0;i--){
    s2+=s[i];
  }
  for(int i=0;i<s2.size();i++){
    //cout<<s2<<endl;
    for(int j=0;j<4;j++){
      if(o[j]==s2.substr(i,o[j].size())){
      //  s2=s2.substr(i+o[j].size(),s2.size()-(i+o[j].size()-1));
      x+=o[j].size();
      i+=o[j].size()-1;
      }
    }

  }
  if(s2.size()==x){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }


  return 0;
}


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

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

  int coin500 = 500;
  int amari = n%coin500;
  if(amari<=a){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: u64, b: u64
    }

    println!("{}", if a*b%2==0 {"Even"} else {"Odd"});
}

Measured memory_bytes: 4352