akhauriyash/Code-Regression huggingface dataset:
#define MYDEBUG
#include <bits/stdc++.h>

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
#define EPS = 1e-14;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;

template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}

template<typename T>
class queue {
private:
	static const int MAX_N = 200000;
	T Q[MAX_N];
	int head, tail;
public:
	void initialize() {
		head = tail = 0;
	}
	queue() {
		initialize();
	}
	bool isEmpty() {
		return head == tail;
	}
	bool isFull() {
		return head == (tail + 1) % MAX_N;
	}
	void enqueue(T x) {
		if (isFull()) {
			printf("Queue is full: (head, tail) = (%d, %d)\n", head, tail);
			return;
		}
		Q[tail] = x;
		tail = (tail + 1) % MAX_N;
	}
	T dequeue() {
		if (isEmpty()) {
			printf("Queue is empty: (head, tail) = (%d, %d)\n", head, tail);
			return Q[head];
		}
		T ret = Q[head];
		head = (head + 1) % MAX_N;
		return ret;
	}
};

typedef struct pp {
	string name;
	int t;
} P;

int n, q, c, elaps;
queue<P> Q;
P u;
void solve() {
	cin >> n >> q;
	rep(i,0,n)
	{
		cin >> u.name >> u.t;
		Q.enqueue(u);
	}
	while (!Q.isEmpty()) {
		P p = Q.dequeue();
		c = min(p.t, q);
		p.t -= c;
		elaps += c;
		if (p.t > 0) {
			Q.enqueue(p);
		} else {
			printf("%s %d\n", p.name.c_str(), elaps);
		}
	}
}

int main() {
	solve();
}

Measured memory_bytes: 8740
import java.util.*;

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

        int n = sc.nextInt();
        int[] a = new int[n];

        Map<Long, Integer> map = new HashMap<>();
        boolean flag = true;
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
            if(flag){
                Map<Long, Integer> prime = primeFactorization(a[i]);
                for(Long l : prime.keySet()){
                    if(map.containsKey(l)){
                        flag = false;
                    }else{
                        map.put(l, 1);
                    }
                }
            }
        }

        System.out.println(flag ? "pairwise coprime" : gcd(a) == 1 ? "setwise coprime" : "not coprime");

    }
    
    static Map<Long, Integer> primeFactorization(long n){
        Map<Long, Integer> result = new TreeMap<>();
        if(isPrime(n)){
            result.put(n, 1);
            return result;
        }
        for(long i = 2; i * i <= n; i++){
            if(n % i != 0){
                continue;
            }
            int p = 0;
            while(n % i == 0){
                p++;
                n /= i;
            }
            result.put(i, p);
        }
        if(n != 1){
            result.put(n, 1);
        }
        return result;
    }

    static boolean isPrime(long n){
        if(n == 2){
            return true;
        }
        if(n < 2 || n % 2 == 0){
            return false;
        }
        long sqrt = (long)Math.sqrt(n);
        for(long i = 3; i <= sqrt; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }


    static int gcd(int a, int b){
        return b == 0 ? a : gcd(b, a % b);
    }

    static int gcd(int[] a){
        int result = 0;
        for(int i : a){
            result = gcd(result, i);
        }
        return result;
    }
}


Measured memory_bytes: 66628
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>
using namespace std;
using ll = long long;

int main() {
	int H, W;
	cin >> H >> W;
	string S;
	vector<string> C(H);
	for (int i = 0; i < H; i++) {
		cin >> S;
		C[i] = S;
	}
	for (int i = 0; i < H; i++) {
		cout << C[i] << endl;
		cout << C[i] << endl;
	}
	return 0;
}

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

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

string S, T;

bool valid() {
    set<char> se;
    FORE(e, S) se.emplace(e);
    FORE(e, T) if (se.count(e) == 0) {
        return false;
    }
    return true;
}

set<int> init_idx[26];
int get_nxt(int val, int prev) {
    auto itr = init_idx[val].upper_bound(prev);
    if (itr == end(init_idx[val])) {
        return *begin(init_idx[val]);
    } else {
        return *itr;
    }
}

int main(void) {
    cin >> S;
    cin >> T;
    if (!valid()) {
        cout << -1 << endl;
        return 0;
    }

    REP(i, (int)S.length()) {
        init_idx[S[i] - 'a'].emplace(i);
    }

    LL ans = 0;
    int prev = -1;
    FORE(e, T) {
        const int cur_val = e - 'a';

        const auto nxt = get_nxt(cur_val, prev);
        assert(S[nxt] == e);
        if (prev < nxt) {
            ans += nxt - prev;
            prev = nxt;
        } else {
            ans += (int)S.length() - 1 - prev;
            ans += nxt + 1;
            prev = nxt;
        }

        //DEBUG(ans)
    }

    cout << ans << endl;
}


Measured memory_bytes: 5120
#include<iostream>

using namespace std;

bool is_even_string(string s){
  int len = s.length();
  if(len == 1)
    return true;
  else if(len % 2 == 0){
    int halflen = len / 2;
    for(int i = 0; i < halflen; i++){
      if(s[i] != s[halflen + i]) return false;
    }
    
    return true;
  }

  return false;
}

int main(){
  string s;
  
  while(cin >> s){
    while(true){
      int len = s.length();
      if(len == 2){
	cout << 1 << endl;
	break;
      } else {
	s.resize(len - 2);
	if(is_even_string(s)){
	  cout << s.length() << endl;
	  break;
	}
      }
    }
  }

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


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

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){
	int a,b,c;
	cin>>a>>b>>c;

	if(a<=c && c<=b) puts("Yes");
	else puts("No");
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#define N 1000005
using namespace std;
long long n, s, M=1e9+7, fac[N]={1,1}, inv[N]={1,1}, fin[N]={1,1};

int main() {
	int i;
	cin>>n;
	for(i=2; i<=n; i++) {
		fac[i] = fac[i-1] * i % M;
		inv[i] = inv[M%i] * (M-M/i) % M;
		fin[i] = fin[i-1] * inv[i] % M;
	}
	for(i=(n+1)/2; i<n; i++) s += fac[i] * fac[i-1] % M * fin[2*i-n] % M;
	cout<<(fac[n] - s%M + M) % M;
	return 0;
}

Measured memory_bytes: 23680
#!/usr/bin/env python3
import sys
from decimal import *


def solve(A: int, B: float):
    print(int(A*B))
    return


# Generated by 1.1.7.1 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()
    A = int(next(tokens))  # type: int
    B = Decimal(next(tokens))  # type: Decimal
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10068
#include <stdio.h>
 
int main(void)
{
  int x[20];
  int i = 0;
  int max = 0;
  int sum = 0;
  int n = 0;
  scanf("%d", &n);
  while(i < n){
    scanf("%d", &x[i]);
    i++;
  }
  i = 0;
  while(i < n){
    if(max <= x[i]){
      max = x[i];
      sum++;
    }
    i++;
  }
  
  printf("%d", sum);
  return(0);
}


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

int main() {
  int N, a;
  cin >> N;  
  int A[N+1];
  for (int i=1; i<N+1; i++){
    A[i]=0;
  }
  for (int i=0; i<N-1; i++){
    cin >> a;
    A[a]++;
  }
  for (int i=1; i<N+1; i++){
    cout << A[i] << endl;
  }
}

Measured memory_bytes: 4320
import java.util.*;
import java.io.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();

    TreeMap<Integer, Integer> hashMap = new TreeMap<>();

    for (int i = 0; i < N; i++) {
      int A = sc.nextInt();
      hashMap.put(A,i);
    }

    sc.close();

    PrintWriter out = new PrintWriter(System.out);

    int length = hashMap.size();

    for (Map.Entry<Integer, Integer> map : hashMap.entrySet()) {
      out.print(map.getValue() + 1);
      if(map.getKey() != length) {
        out.print(" ");
      }
    }

    out.println("");
    out.flush();
    
  }

}

Measured memory_bytes: 66080
import java.util.*;
import java.util.stream.Collectors;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 16MB stack
        Thread thread = new Thread(null, new Main(), "", 16 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    // int a = Integer.parseInt(scanner.nextLine());
    // int[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    static void solve(Scanner scanner) {
        int sum = 0;
        int minus = 0;
        for (int i = 0; i < 5; i++) {
            int n = Integer.parseInt(scanner.nextLine());
            sum += (n / 10) * 10;
            if (n % 10 != 0) {
                sum += 10;
                minus = Math.max(minus, 10 - n % 10);
            }
        }
        System.out.println(sum - minus);

    }

}


Measured memory_bytes: 22612
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 1005;
int x[maxN], y[maxN], r[maxN];
ld dist[maxN][maxN];
ld sqr(ld x) {
    return x * x;
}
ld getDist(int i, int j) {
    ld f = sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j]));
    return max((ld)0, f - r[i] - r[j]);
}
bool used[maxN];
ld dst[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> x[0] >> y[0];
    r[0] = 0;
    cin >> x[1] >> y[1];
    r[1] = 0;
    cin >> n;
    n++;
    for (int i = 2; i <= n; i++) {
        cin >> x[i] >> y[i] >> r[i];
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            dist[i][j] = getDist(i, j);
        }
    }
    for (int i = 1; i <= n; i++) {
        dst[i] = 1e18;
    }
    dst[0] = 0;
    for (int iter = 0; iter <= n; iter++) {
        pair < ld, int > best = make_pair((ld)1e18 + 228, -1);
        for (int i = 0; i <= n; i++) {
            if (!used[i]) best = min(best, make_pair(dst[i], i));
        }
        if (best.second == -1) break;
        int v = best.second;
        used[v] = true;
        for (int j = 0; j <= n; j++) {
            dst[j] = min(dst[j], dst[v] + dist[v][j]);
        }
    }
    cout << fixed << setprecision(10) << dst[1];
    return 0;
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
using ll = long long;

int main(){
  ll h,w;
  cin>>h>>w;
  ll ans;
  if(h==1||w==1)ans=1;
  else ans=((h+1)/2)*((w+1)/2)+(h/2)*(w/2);
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 256
p = [list(map(int, input().split())) for _ in range(3)]
if p[0][0] - p[0][1] == p[1][0] - p[1][1] == p[2][0] - p[2][1] and p[0][1] - p[0][2] == p[1][1] - p[1][2] == p[2][1] - p[2][2] and p[0][0] - p[1][0] == p[0][1] - p[1][1] == p[0][2] - p[1][2] and p[1][0] - p[2][0] == p[1][1] - p[2][1] == p[1][2] - p[2][2]:
        print('Yes')
        
else:
    print('No')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
const int maxn = 100005;

void go() {
    ll plmx = -1e18;
    ll plmi = 1e18;
    ll mimx = -1e18;
    ll mimi = 1e18;
    int n;
    cin >> n;
    f1(n) {
        ll x, y;
        cin >> x >> y;
        plmx = max(plmx,x + y); 
        plmi = min(plmi,x + y);
        mimx = max(mimx,x - y);  
        mimi = min(mimi,x - y);  
    }
    cout << max(plmx - plmi, mimx - mimi) << '\n';

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint sh, sm, th, tmm, k;

llint get(llint h, llint m)
{
	return h*60+m;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> sh >> sm >> th >> tmm >> k;
	llint s = get(sh, sm), t = get(th, tmm);
	
	cout << max(0LL, t-k-s) << endl;
	
	return 0;
}

Measured memory_bytes: 3652
// https://atcoder.jp/contests/abc168/tasks/abc168_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

double deg2rad(double degree) { return degree * M_PI / 180.0; }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    // 長針の進む角度
    double v1 = 30 * H + 0.5 * M;
    // 短針の進む角度
    double v2 = 6 * M;
    printf("%.10f\n", sqrt(A * A + B * B - 2 * A * B * cos(deg2rad(v1 - v2))));

    return 0;
}


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

long long N;
long long ans[5050];


int check(long long p1, long long p2){
	int i = 1;
	while(p1>0 || p2>0){
		if((p1&1) != (p2&1)){
			return i;
		}
		p1 = (p1>>1);
		p2 = (p2>>1);
		i++;
	}
	exit(1);
}


int main(){
	cin >> N;
	long long num = 1;
	while(num < N){
		num *= 2;
	}

	for(long long i = 0; i < num; i++){
		ans[i] = i;
	}


	for(long long i = 0; i < N; i++){
		for(long long j = i + 1; j < N; j++){
			cout << check(ans[i], ans[j]);
			if(j != N-1){
				cout << " ";
			}else{
				cout << endl;
			}
		}
	}
}


Measured memory_bytes: 512
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
//    String s=sc.next();
//    int x=sc.nextInt();
    int a=sc.nextInt();
    int b=sc.nextInt();
//    int[] a={sc.nextInt(),sc.nextInt(),sc.nextInt()};
//    Arrays.sort(a);
    System.out.println(a-b+1);
  }
}


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

int main()
{ int n,m,a,b,c;
  while(~scanf("%d %d",&n,&m))
  {  a=n+m;
     b=n-m;
     c=n*m;
    if(a<b)
        a=b;
    if(a<c)
        a=c;
    printf("%d\n",a);

  }
    return 0;
}


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

int main() {
    long long N;
    cin >> N;
    vector<long long>A(N-1);
    vector<long long>ans(N);
    ans[0] = 0;
    for(int i = 0; i < N-1; i++) {
        cin >> A[i];
        ans[A[i]-1]++;
    }
    for(int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
}


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

#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define Rep(i,n,m) for(int i = (int)(n); i < (int)(m);i++)
#define rrep(i,n) for(int i = (int)(n); i > -1;i--)

#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

template<typename T>
void swap(T*,T*);

int main()
{
    int K,X;
    cin >> K >> X;
    Rep(i,X - K + 1,X + K)
    {
        cout << i << " "; 
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=924844033;
ll f[4010][2010][2],fac[2010];
int nxt[5010],e[5010],pre[5010];
int read()
{
	int x=0;char c=getchar(),flag='+';
	while(!isdigit(c)) flag=c,c=getchar();
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return flag=='-'?-x:x;
}
int main()
{
	int n=read(),k=read(),cnt=0;
	for(int i=1;i<=n;i++) 
	{
		if(i+k<=n) nxt[i]=i+k+n,pre[i+k+n]=i;
		if(i-k>=1) nxt[i-k+n]=i,pre[i]=i-k+n;
	}
	for(int i=1;i<=2*n;i++)
	{
		if(!pre[i])
		{
			int x=i;
			cnt++;
			while(nxt[x]) x=nxt[x],e[++cnt]=1;
		}
	}
//	cout<<cnt;
//for(int i=1;i<=cnt;i++) cout<<e[i]<<' ';
	f[0][0][0]=1;
	for(int i=1;i<=cnt;i++)
	{
		for(int j=0;j<=n;j++)
		{
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%mod;
			if(e[i]&&j) f[i][j][1]=f[i-1][j-1][0];
		}
	}
	ll ans=1;
	for(int i=1;i<=n;i++) ans=ans*i%mod;
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	for(int i=1;i<=n;i++)
	{
		if(i&1) ans=(ans-(f[cnt][i][0]+f[cnt][i][1])*fac[n-i]%mod+mod)%mod;
		else ans=(ans+(f[cnt][i][0]+f[cnt][i][1])*fac[n-i])%mod;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 125952
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int n;
    cin >> n;
    vector<int> v;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        v.emplace_back(a);
        v.emplace_back(b);
        v.emplace_back(c);
    }
    sort(v.begin(), v.end(), greater<>());
    for (int i = 0; i < n; ++i) {
        ans += v[i*2+1];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2420
#include<stdio.h>
#include<vector>

int main()
{
	char c[105];
	long long k;
	int i;

	scanf("%s", c);
	scanf("%lld", &k);

	for (i = 0; ; ++i)
	{
		if (i + 1 == k)
			break;
		if (c[i] > '1')
			break;
	}

	printf("%c\n", c[i]);

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
double xx,yy;
double m(double x1, double y1, double x2, double y2){
  double a,b,c,z;
  a=sqrt(((xx-x1)*(xx-x1))+((yy-y1)*(yy-y1)));
  b=sqrt(((xx-x2)*(xx-x2))+((yy-y2)*(yy-y2)));
  c=sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
  z=(a+b+c)/2;
  return (sqrt(z*(z-a)*(z-b)*(z-c)));
}
int main(){
  double x[21],y[21];
  int i=0;
  double s=0;
  while(scanf("%lf,%lf",&x[i],&y[i])!=EOF){
    if(i==0){
      xx=x[0];
      yy=y[0];
    }
    if(i>1){
      s+=m(x[i-1],y[i-1],x[i],y[i]);
    }
    i++;
  }
  printf("%f\n",s);
  return 0;
}

Measured memory_bytes: 652
#include<stdio.h>
long int s[10000], t[500];
int n, q;
int searching(int key)
{
    int i=0;

    s[n]=key;

    while(s[i]!=key) i++;

    if(i==n) return 0;
    else return 1;
}
int main()
{
    int i, sum=0;
    long int key;

    scanf("%d", &n);
    for(i=0;i<n;i++)
        scanf("%d", &s[i]);
    scanf("%d", &q);
    for(i=0;i<q;i++)
        scanf("%d", &t[i]);

    for(i=0;i<q;i++)
    {
        key=t[i];
        if(searching(key)) sum++;
    }

    printf("%d\n", sum);

    return 0;
}

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

int main(){
#ifndef ONLINE_JUDGE
//	freopen("in.txt","r",stdin);
#endif
	//read
	int n;
	cin>>n;
	long long sum=0,now,past;
	cin>>past;
	for(int i=1;i<n;++i){
		cin>>now;
		if(now<past){
			sum+=past-now;
			now=past;
		}
		past=now;
	}
	cout<<sum<<endl;
	return 0;
} 

Measured memory_bytes: 3632
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

char board[2003][2003];
int vertex[2003][2003];
int edgeH[2003][2003];
int edgeV[2003][2003];

int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) {
    scanf("%s", board[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      vertex[i + 1][j + 1] = (board[i][j] == '1') + vertex[i][j + 1] + vertex[i + 1][j] - vertex[i][j];
      edgeH[i + 1][j + 1] = (board[i][j] == '1' && board[i][j + 1] == '1') + edgeH[i][j + 1] + edgeH[i + 1][j] - edgeH[i][j];
      edgeV[i + 1][j + 1] = (board[i][j] == '1' && board[i + 1][j] == '1') + edgeV[i][j + 1] + edgeV[i + 1][j] - edgeV[i][j];
    }
  }
  for (int i = 0; i < q; i++) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    x1--, y1--;
    int vertices = vertex[x2][y2] - vertex[x2][y1] - vertex[x1][y2] + vertex[x1][y1];
    int edges =
      edgeV[x2 - 1][y2] - edgeV[x2 - 1][y1] - edgeV[x1][y2] + edgeV[x1][y1] +
      edgeH[x2][y2 - 1] - edgeH[x2][y1] - edgeH[x1][y2 - 1] + edgeH[x1][y1];
    printf("%d\n", vertices - edges);
  }
  return 0;
}

Measured memory_bytes: 52608
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
int main() 
{
    buff();
    long long n;
    cin >> n;
    long long ans = 0;
    for(long long i = 1; i <= n; ++i)
    {
        long long mul = 1ll;
        while(mul * i <= n) {
            ans += (mul * i);
            mul++;
        }
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 3620
<?php
    $count = 0;
    $temp = 0;
    $NMC = explode(" ",trim(fgets(STDIN)));
    $N = $NMC[0];
    $M = $NMC[1];
    $C = $NMC[2];
  
    $B = explode(" ",trim(fgets(STDIN)));
    for ($i = 0; $i < $N; $i++) {
        $A = explode(" ",trim(fgets(STDIN)));
        for ($j = 0; $j < $M; $j++) {
            $temp += $A[$j] * $B[$j];
            //echo $temp."\n";
        }
        if ($temp + $C > 0) $count++;
        //echo $temp + $C;
        $temp = 0;
    }
  
  echo $count;
  

?>

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define maxn 1000005
using namespace std;

bool prime[maxn];
vector < int > a;

void seive()
{
    prime[0] = prime[1] = 1;
    int tmp = sqrt(maxn);

    for(int i = 2; i <= tmp; i++){
        if(prime[i] == 1) continue;

        for(int j = i * i; j <= maxn; j += i) prime[j] = 1;
    }
}

int main()
{
    int x;

    cin >> x;

    seive();

    for(int i = 0; i < maxn; i++){
        if(prime[i] == 0) a.push_back(i);
    }

    int l = lower_bound(a.begin(), a.end(), x) - a.begin();

    cout << a[l] << endl;

    return 0;
}


Measured memory_bytes: 1916
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n, k;
  cin>>n>>k;
  double ans = 0;
  double s = 0;
  double p[n];
  REP(i, n){
    cin>>p[i];
  }
  REP(i, n){
    if(i < k - 1){
      s += (p[i] + 1.0) / 2.0;
    }else if(i == k - 1){
      s += (p[i] + 1.0) / 2.0;
      ans = max(ans, s);
    }else{
      s += (p[i] + 1.0) / 2.0;
      s -= (p[i - k] + 1.0) / 2.0;
      ans = max(ans, s);
    }
  }
  cout<<fixed<<setprecision(7)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A

#include <iostream>
#include <cstdio>
using namespace std;

int V, E, r, s, t, d;
// int K[100010][100010]; 隣接行列を使おうと思ったがメモリが怖い。
// ので、structの配列で、隣接配列を使ってみようと思う。

struct Edge {
  int cur;
  int dst;
  int cost;
};

Edge edges[500010];

long long infty = 10000*100000+100; // ゆえにC[]はlong longを入れる。
long long C[100010]; // 最短コストの「上限」。最終的には答えが入る。

int main() {
  // 初期化
  for (int i=0; i<100010; i++) {
    C[i] = infty;
  }
  // 入力
  scanf("%d%d%d", &V, &E, &r);
  for (int i=0; i<E; i++) {
    scanf("%d%d%d", &s, &t, &d);
    edges[i] = { s, t, d };
  }
  // Bellman-Ford
  C[r] = 0; // 始点はコスト0。
  for (int i=0; i<V-1; i++) { // V-1回繰り返す。iには「特別な」意味はない。
    int change = 0; // 最短経路がV-1個の頂点をつないでいる確率は低い。更新しなくてよくなったらもう繰り返さない。
    for (int j=0; j<E; j++) { // すべての頂点に対し
      if (C[edges[j].dst] > C[edges[j].cur] + edges[j].cost) {
	C[edges[j].dst] = C[edges[j].cur] + edges[j].cost;
	change++;
      }
    }
    if (change == 0) {
      break;
    }
  }
  for (int i=0; i<V; i++) {
    if (C[i] < infty) {
      printf("%lld\n", C[i]);
    } else {
      printf("INF\n");
    }
  }
}

Measured memory_bytes: 7704
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int n;
    cin >> n;
    int taro = 0, hanako = 0;
    for(int i = 0; i < n; i++){
	  string a, b;
	  cin >> a >> b;
	  if (a > b) taro += 3;
	  else if (a < b) hanako += 3;
	  else taro++, hanako++;
	}
	cout << taro << " " << hanako << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3224
#include<stdio.h>

int main()
{
  long int L;
  long int R;
  int min;
  
  scanf("%ld%ld", &L, &R);
  
  if (R - L >= 2018)
  {
    printf("0");
    return 0;
  }
  
  if (R / 2019 != L / 2019)
  {
    printf("0");
    return 0;
  }
  
  min = (L % 2019) * ((L + 1) % 2019) % 2019;
  for (int i = L; i < R; i++)
  {
    for (int j = i + 1; j <= R; j++)
    {
      if (min > (i % 2019) * (j % 2019) % 2019) min = (i % 2019) * (j % 2019) % 2019;
    }
  }
  
  printf("%d", min);
  return 0;
}

Measured memory_bytes: 128
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  int[string] words;
  auto f = true;

  auto prev = readln.chomp;
  words[prev]++;

  foreach (i; 1..n) {
    auto w = readln.chomp;
    if (words.get(w, 0) || prev[$-1] != w[0]) {
      f = false;
    } else {
      words[w]++;
    }
    prev = w;
  }

  if (f) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


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

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

  vector<pair<int, int>> magics(N);
  for(int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    magics[i] = make_pair(a, b);
  }

  // dp[i][j] := using magics[0: i), toki can reduce monster's power j with magical power dp[i][j].
  vector<vector<long long>> dp(N + 1, vector<long long>(H + 1));
  for(int j = 1; j <= H; j++){
    dp[0][j] = 1e9;
  }
  for(int i = 1; i <= N; i++){
    int effect = magics[i - 1].first, cost = magics[i - 1].second;
    for(int j = 0; j <= H; j++){
      dp[i][j] = dp[i - 1][j];
      if(j - effect >= 0){
        dp[i][j] = min(dp[i][j], dp[i][j - effect] + cost);
      }else{
        dp[i][j] = min(dp[i][j], static_cast<long long>(cost));
      }
    }
  }
  cout << dp[N][H] << endl;
  
}


Measured memory_bytes: 78592
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

bool cant[maxn];
int f[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int x;
    cin>>x;
    cant[x]=1;
  }
  f[0]=1;
  for(int i=1;i<=n;i++){
    if(cant[i])continue;
    int tt =f[i-1]+f[i-2];
    if(tt>=mod)tt-=mod;
    f[i]=tt;
  }
  cout<<f[n]<<endl;
  return 0;
}

Measured memory_bytes: 768
import Base: -
function -(s::AbstractString, t::AbstractString)
    res = 0
    for n in 1:length(s)
        s[n]≠t[n] && (res+=1)
    end
    return res
end
function main()
    S, T = readlines()
    len = length(T)
    t = len
    for n in 1:length(S)-len+1
        temp = S[n:n+len-1] - T
        temp < t && (t=temp)
    end
    return println(t)
end
main()


Measured memory_bytes: 169916
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main (){
    int k;
    cin >> k;
    long long sum=0;
    for (int i=2;i<=k;i+=2){
        for(int j=1;j<=k;j+=2){
            sum++;
        }
    }
    cout << sum << endl;



   return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;


int main()
{
	int K,A,B;
	cin>>K>>A>>B;
	bool ans = false;
	for(int i = A; i <= B; i++){
		if( i % K == 0){
			ans = true;
			break;
		}
	}
	if(ans == true){
		cout<<"OK"<<endl;
	}else{
		cout<<"NG"<<endl;
	}
	return 0;
}



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

struct Dice {
	vector<int> val;
	Dice(){ val.resize(6); }
	bool operator == (const Dice &t) const {
		return val == t.val;
	}
	bool operator != (const Dice &t) const {
		return val != t.val;
	}
	bool operator < (const Dice &t) const {
		return val < t.val;
	}
	void rotate_right(){
		int tmp = val[1];
		val[1] = val[2];
		val[2] = val[4];
		val[4] = val[3];
		val[3] = tmp;
	}
	void roll_front(){
		int tmp = val[0];
		val[0] = val[1];
		val[1] = val[5];
		val[5] = val[4];
		val[4] = tmp;
	}
	void roll_right(){
		int tmp = val[0];
		val[0] = val[3];
		val[3] = val[5];
		val[5] = val[2];
		val[2] = tmp;
	}
	vector<Dice> all_pattern(){
		vector<Dice> res;
		Dice d = *this;
		for (int i = 0; i < 6; i++){
			for (int j = 0; j < 4; j++){
				res.push_back(d);
				d.rotate_right();
			}
			if (i == 0) d.roll_front();
			else if (i < 5) d.roll_right();
			else d.roll_front();
		}
		return res;
	}
};

struct UnionFind {
	vector<int> parent;
	
	UnionFind(int n){
		parent.resize(n);
		for (int i = 0; i < n; i++){
			parent[i] = i;
		}
	}
	
	int find(int x){
		if (parent[x] == x) return x;
		return parent[x] = find(parent[x]);
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
	
	bool unite(int x, int y){
		x = find(x);
		y = find(y);
		if (x == y) return false;
		parent[x] = y;
		return true;
	}
};

map<string, int> ctoi;
int n;
vector<Dice> dices;

bool check(const vector<Dice> &A, const vector<Dice> &B)
{
	for (int i = 0; i < A.size(); i++){
		for (int j = 0; j < B.size(); j++){
			if (A[i] == B[j]) return true;
		}
	}
	return false;
}

void solve()
{
	vector<vector<Dice> > pats;
	UnionFind uf(n);
	
	for (int i = 0; i < n; i++){
		pats.push_back(dices[i].all_pattern());
	}
	
	int res = 0;
	
	for (int i = 0; i < n; i++){
		for (int j = i + 1; j < n; j++){
			vector<Dice> &A = pats[i];
			vector<Dice> &B = pats[j];
			if (check(A, B)){
				res += uf.unite(i, j);
				continue;
			}
		}
	}
	
	printf("%d\n", res);
}

int main()
{
	ctoi["Red"] = 0;
	ctoi["Yellow"] = 1;
	ctoi["Blue"] = 2;
	ctoi["Magenta"] = 3;
	ctoi["Green"] = 4;
	ctoi["Cyan"] = 5;
	
	while (scanf("%d", &n), n){
		dices.clear();
		for (int i = 0; i < n; i++){
			Dice d;
			for (int j = 0; j < 6; j++){
				string str;
				cin >> str;
				d.val[j] = ctoi[str];
			}
			dices.push_back(d);
		}
		solve();
	}
	
	return 0;
}

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

int main(){
	string a,b,c;	cin>>a>>b>>c;
	if(a[a.length()-1]==b[0] && b[b.length()-1]==c[0])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    PX = [list(map(int, input().split())) for _ in range(M)]

    total = sum(T)
    for i in range(M):
        print(total-T[PX[i][0]-1]+PX[i][1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
cnt = 0
for i in data:
    if i % 2 != 0:
        cnt += 1
if cnt % 2 == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 14112
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	stack<long> s1;
	rep(i,0,n){
		long tmp;
		cin >> tmp;
		s1.push(tmp);
	}
	
	stack<long> s2;
	rep(i,0,n){
		long a = s1.top();
		s1.pop();
		if(i % 2 == 0)
			cout << a << " ";
		else 
			s2.push(a);
	}
	
	while(!s2.empty()){
		long a = s2.top();
		s2.pop();
		cout << a << " ";
	}
	
	P("");
	ret 0;
}

Measured memory_bytes: 3840
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;

    cout << n*(n+1)/2<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B;cin >> A >> B;
  string S;cin >> S;
  bool issat = true;
  set<char> st;
  rep(i,10) st.insert('0'+i);
  rep(i,A) if(!st.count(S[i]))issat=false;
  if(S[A] != '-') issat=false;
  repp(i,A+1,A+B+1) if(!st.count(S[i]))issat=false;
  YesNo(issat);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		for (;;){
			int n = sc.nextInt();
			int x = sc.nextInt();
			int num=0;
			if(n==0 && x==0) break;
			for(int i=1; i<=n; i++){
				for(int j=i+1; j<=n; j++){
					for(int k=j+1; k<=n; k++){
						if(i+j+k==x) num++;
					}
				}
			}
			System.out.println(num);
		}
	}
}

Measured memory_bytes: 26352
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int r, d, x;
  cin >> r >> d >> x;
  for (int i = 1; i <= 10; i++) {
    x = r * x - d;
    cout << x << endl;
  }
  return 0;
}

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

typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a + b == 15){
        cout << '+' << endl;
    }else if(a * b == 15){
        cout << '*' << endl;
    }else{
        cout << "x" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int CeilIndex(std::vector<int> &v, int l, int r, int key) {
    while (r-l > 1) {
    int m = l + (r-l)/2;
    if (v[m] >= key)
        r = m;
    else
        l = m;
    }
 
    return r;
}
 
int LongestIncreasingSubsequenceLength(vector<ll> &v) {
    if (v.size() == 0)
        return 0;
 
    std::vector<int> tail(v.size(), 0);
    int length = 1; // always points empty slot in tail
 
    tail[0] = v[0];
    for (size_t i = 1; i < v.size(); i++) {
        if (v[i] < tail[0])
            // new smallest value
            tail[0] = v[i];
        else if (v[i] > tail[length-1])
            // v[i] extends largest subsequence
            tail[length++] = v[i];
        else
            // v[i] will become end candidate of an existing subsequence or
            // Throw away larger elements in all LIS, to make room for upcoming grater elements than v[i]
            // (and also, v[i] would have already appeared in one of LIS, identify the location and replace it)
            tail[CeilIndex(tail, -1, length-1, v[i])] = v[i];
    }
 
    return length;
}

const double PI = acos(-1.0);

int main() {
    ios::sync_with_stdio(false);
    ll X, Y, a, b;
    cout.precision(20);
    cin >> X >> Y >> a >> b;
    ll lx = min(X, a);
    ll rx = max(X, a);
    ll ly = min(Y, b);
    ll ry = max(Y, b);
    bool di;
    if (X < a && Y < b) di = 1;
    else if (X > a && Y > b) di = 1;
    else di = 0;
    int N;
    cin >> N;
    vector<PP> G;
    for (int i = 0;i < N;i++) {
    	ll x, y;
    	cin >> x >> y;
    	if (x >= lx && x <= rx && y >= ly && y <= ry) {
    		if (!di) x = -x;
    		G.push_back(make_pair(x, y));
    	}
    }
    if (lx == rx) {
    	double res = 100.0 * (ry - ly);
    	if (G.size() != 0) res += (PI - 2.0) * 10.0;
    	cout << res << endl;
    	return 0;
    }
    if (ly == ry) {
    	double res = 100.0 * (rx - lx);
    	if (G.size() != 0) res += (PI - 2.0) * 10.0;
    	cout << res << endl;
    	return 0;
    }
    sort(G.begin(), G.end());
    vector<ll> M;
    for (int i = 0;i < G.size();i++) M.push_back(G[i].second);
    // Longest increasing subsequence.
    int num = LongestIncreasingSubsequenceLength(M);
    int diff = min(rx - lx, ry - ly);
    double v = 100.0 * (rx - lx + ry - ly) - 10.0 * num * (2.0 - PI/2);
    if (num > diff) {
    	v += 10.0 * PI / 2;
    }
    cout << v << endl;
    return 0;
}

Measured memory_bytes: 4848
#include <stdio.h>

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

int main()
{
    long long n,x;
    scanf("%lld%lld",&n,&x);
    long long gcd=ggccdd(n,x);
    long long ans=n/gcd;
    ans*=3;ans-=3;ans*=gcd;
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>

using namespace std;
using PII = pair<int, int>;

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

	vector<int> x(n, 0), y(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}

	map<PII, set<PII>> pqs;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) {
				continue;
			}
			int p = x[j] - x[i];
			int q = y[j] - y[i];

			pqs[make_pair(p,q)].insert(make_pair(i, j));
		}
	}

	int max_move = 0;
	for (auto pq: pqs) {
		int move = pq.second.size();
		max_move = max(max_move, move);
	}

	int ans = n - max_move;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640