akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;


#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 rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	string S;
	string T;
	cin >> S>> T;
	int ans = 0;

	rep(i, 3) {
		if (S.compare(i,1,T,i,1)==0) {
			ans++;
		}
	}
	
	print(ans);

}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    auto x = readLong();
    long n = 1;
    while(true) {
        if(n * (n+1) / 2 >= x) {
            writeln(n);
            return;
        }
        ++n;
    }
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	static int[] G => ReadLine().Split().Select(i => int.Parse(i) - 1).ToArray();
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static int N;
	public K()
	{
		var I = G;
		N = I[0] + 1;
		WriteLine(ToString(Calc(G, G, I[1])));
	}
	static string ToString(int[] p) => string.Join(" ", p.Select(i => i + 1));
	static int[] Calc(int[] p, int[] q, int K)
	{
		int[] P = Inv(p), Q = Inv(q), x = Pow(Mult(q, P, Q, p), K / 6), y = Inv(x);
		switch (K % 6)
		{
			case 0: return Mult(x, p, y);
			case 1: return Mult(x, q, y);
			case 2: return Mult(x, q, P, y);
			case 3: return Mult(x, q, P, Q, y);
			case 4: return Mult(x, q, P, Q, p, Q, y);
			default: return Mult(x, q, P, Q, p, p, Q, y);
		}
	}
	static int[] Inv(int[] a)
	{
		var c = new int[N];
		for (var i = 0; i < N; i++) c[a[i]] = i;
		return c;
	}
	static int[] Mult(int[] a, int[] b) => MakeArray(N, i => a[b[i]]);
	static int[] Mult(params int[][] a) => a.Aggregate(Mult);
	static int[] Pow(int[] a, int b)
	{
		if (b < 0) return Inv(Pow(a, -b));
		var p = new int[N];
		var f = new bool[N];
		for (var i = 0; i < N; i++)
			if (!f[i])
			{
				var l = new List<int>();
				var x = i;
				while (!f[x]) { l.Add(x); f[x] = true; x = a[x]; }
				var C = l.Count;
				for (var j = 0; j < C; j++) p[l[j]] = l[(j + b) % C];
			}
		return p;
	}
}


Measured memory_bytes: 37952
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>

using namespace std;

const int MAX=100;
const int MAX_cap=10000;

class edge
{
public:
	int to,cap,rev;
	edge(){}
	edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
};

vector<edge> G[MAX];
int level[MAX];//s->v distance
int iter[MAX];

void add_edge(int from,int to,int cap)
{
	G[from].push_back(edge(to,cap,G[to].size()));
	G[to].push_back(edge(from,0,G[from].size()-1));
	return;
}

void bfs(int s)
{
	memset(level,-1,sizeof(level));
	queue<int> Q;
	level[s]=0;
	Q.push(s);
	
	while(!Q.empty())
	{
		int v=Q.front();Q.pop();
		for(int i=0;i<G[v].size();i++)
		{
			edge e=G[v][i];
			if(e.cap>0&&level[e.to]<0)
			{
				level[e.to]=level[v]+1;
				Q.push(e.to);
			}
		}
	}
	return;
}

int dfs(int v,int t,int f)
{
	if(v==t)return f;
	for(int &i=iter[v];i<G[v].size();i++)
	{
		edge &e=G[v][i];
		if(e.cap>0&&level[v]<level[e.to])
		{
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0)
			{
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int maxflow(int s,int t)
{
	int flow=0;
	while(1)
	{
		bfs(s);
		if(level[t]<0)return flow;
		memset(iter,0,sizeof(iter));
		int f;
		while((f=dfs(s,t,MAX_cap))>0)flow+=f;
	}
}

int main()
{
	int V,E;
	cin>>V>>E;
	int u,v,c;
	for(int i=0;i<E;i++)
	{
		cin>>u>>v>>c;
		add_edge(u,v,c);
	}
	cout<<maxflow(0,V-1)<<endl;
	return 0;
}

Measured memory_bytes: 3148
import sys


# sys.stdin = open('c1.in')


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


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n = read_int()
    a = read_int_list()
    b = [0] * n
    p = 0
    q = n - 1
    for i in range(n-1, -1, -1):
        if i % 2 == (n-1) % 2:
            b[p] = a[i]
            p += 1
        else:
            b[q] = a[i]
            q += -1
    return ' '.join(map(str, b))


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


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

using namespace std;
const int mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  int x;
  vector<int> c(n, 0);
  long long res = 1;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == 0) {
      res = (res * (3 - c[x])) % mod;
    } else {
      res = (res * (c[x - 1] - c[x])) % mod;
    }
    c[x]++;
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 640
/* Filename: ABC046C.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main{

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

		while (input.hasNext()) {
			int N = input.nextInt();
			long T = input.nextLong(), A = input.nextLong();
			
			for(int i = 2; i <= N; ++i){
				int Ti = input.nextInt();
				int Ai = input.nextInt();
				long mul = Math.max(T / Ti, A / Ai);
				
				long newT = Ti * mul;
				long newA = Ai * mul;
				if(newT < T || newA < A){
					newT += Ti;
					newA += Ai;
				}
				
				
				T = newT;
				A = newA;
			}
			
			System.out.println(T + A);
		}
	}

}


Measured memory_bytes: 12884
from sys import stdin
import collections
import math


n,x   = [int(x) for x in stdin.readline().rstrip().split()]
arr = [int(x) for x in stdin.readline().rstrip().split()]

ans = 0
if arr[0] > x :
    ans += arr[0] - x 
    arr[0] = x
for i in range(0,n-1):
    s = arr[i] + arr[i+1]
    if s > x :
        d = s-x
        arr[i+1] -= s - x
        ans += d

print(ans)

Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int A,B,C,D;
cin >> A >> B >> C >>D;
while (A > 0 && C > 0) {
    C -= B;
    if (C <= 0) {
        cout << "Yes" << endl;
        return 0;
    }
    A -= D;
}

cout << "No" << endl;

return 0;
}

Measured memory_bytes: 3648
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>
// #include "atcoder/all"

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


// doc: https://shibh308.github.io/library/library/lib/classes/segtree.cpp.html
template<typename T>
struct Segtree{
    int n;
    T op;
    vector<T> elm;
    function<T(T, T)> f;

    Segtree(int n, T init, function<T(T, T)> f, T op = T()) :
        n(n),
        op(op),
        elm(2 * n, init),
        f(f)
    {
        for(int i = n - 1; i >= 1; --i)
            elm[i] = f(elm[2 * i], elm[2 * i + 1]);
    }

    Segtree(int n, vector<T> init, function<T(T, T)> f, T op = T()) :
        n(n),
        op(op),
        elm(2 * n),
        f(f)
    {
        for(int i = 0; i < n; ++i)
            elm[i + n] = init[i];
        for(int i = n - 1; i >= 1; --i)
            elm[i] = f(elm[2 * i], elm[2 * i + 1]);
    }

    void set(int x, T val){
        x += n;
        elm[x] = val;
        while(x >>= 1)
            elm[x] = f(elm[2 * x], elm[2 * x + 1]);
    }

    void update(int x, T val){
        x += n;
        elm[x] = f(elm[x], val);
        while(x >>= 1)
            elm[x] = f(elm[2 * x], elm[2 * x + 1]);
    }

    T get(int x, int y) const{
        T l = op, r = op;
        for(x += n, y += n - 1; x <= y; x >>= 1, y >>= 1){
            if(x & 1)
                l = f(l, elm[x++]);
            if(!(y & 1))
                r = f(elm[y--], r);
        }
        return f(l, r);
    }
};


void solve(long long n, long long k, std::vector<long long> a){
    Segtree<int> seg(300003, 0, [](auto x, auto y){return max(x, y);}, 0);
    for(int i = 0; i < n; ++i){
        int l = a[i] - k;
        int r = a[i] + k + 1;
        seg.update(a[i], seg.get(max(0, l), min(300003LL, 1LL * r)) + 1);
    }
    cout << seg.get(0, 300003) << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


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

public class Main {
	public static void main(String[] args) { new Main(); }
	FS in = new FS();
	PrintWriter out = new PrintWriter(System.out);

	
	
	Main() {
		long a = in.nextLong();
		long b = in.nextLong();
		long k = in.nextLong();
		
		long eat = min(a, k);
		a -= eat; k -= eat;
		
		eat = min(k, b);
		b -= eat;
		k -= eat;

		out.println(a + " " + b);
		out.close();
	}

	
	
	int abs(int x) { if (x < 0) return -x; return x; }
	long abs(long x) { if (x < 0) return -x; return x; }
	int max(int x, int y) { if (x < y) return y; return x; }
	int min(int x, int y) { if (x > y) return y; return x; }
	long max(long x, long y) { if (x < y) return y; return x; }
	long min(long x, long y) { if (x > y) return y; return x; }

	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }

		void intArr(int sz, int[] x) { for (int i = 0; i < sz; i++) x[i] = nextInt(); }
		void longArr(int sz, long[] x) { for (int i = 0; i < sz; i++) x[i] = nextLong(); }
		void doubleArr(int sz, double[] x) { for (int i = 0; i < sz; i++) x[i] = nextDouble(); }
	}
}



Measured memory_bytes: 21332
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = n; i >= b; i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const string lowercase = "abcdefghijklmnopqrstuvwvz";
const string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWvZ";
int gcd(int a, int b){return b ? gcd(b, a % b): a;}

int main()
{
    pi v1, v2, v3, v4;
    cin >> v1.first >> v1.second >> v2.first >> v2.second;
    pi v12 = make_pair(v2.first-v1.first, v2.second-v1.second);
    pi v23 = make_pair(-v12.second, v12.first);
    pi v34 = make_pair(-v23.second, v23.first);
    v3.first = v2.first + v23.first;
    v3.second = v2.second + v23.second;
    v4.first = v3.first + v34.first;
    v4.second = v3.second + v34.second;
    printf("%d %d %d %d\n", v3.first, v3.second, v4.first, v4.second);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define pllll pair<pll,pll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 6e5+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000000006;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 316;
 
int n,x,cnt[MAX],ans;

int main(){
//	cout<<fixed<<setprecision(10);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n;
    rep(i,1,n)cin>>x, cnt[x]++;
    rep(i,1,100000)ans = max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#include <stdio.h>
#include <queue>
#define ll long long
#define pl pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define vvvb vector<vector<vector<bool> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define rep1(i,a) for(ll i = 1;i<a;++i)
#define rrep(i,a) for(ll i = a;i>=0;--i)
#define mod 1000000007
#define inf 10010010010
using namespace std;

//O(logB)
ll mpow(ll a, ll b, ll m){
	if (!b) return 1 % m;
	if (b == 1) return a % m;
	if (b % 2) return (a*mpow(a, b - 1, m)) % m;
	else return mpow((a*a) % m, b / 2, m) % m;
}

bool isKaibun(string s,ll l,ll r){
    for(ll i=l;i<=r;++i){
        if(s[i] != s[r-(i-l)]) return false;
    }
    return true;
}

int main(){
    double l; cin>>l;
    cout<<fixed << setprecision(10)<<((l*l*l)/(3*3*3))<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	//stdin := bufio.NewScanner(os.Stdin)
	input1 :=  splitAndAtoi(readLine())
	n := input1[0]
	
	input2 :=  splitAndAtoi(readLine())
	p := input2

	r := 0
	min := 0
	for i:=0; i<n; i++ {
		pi := p[i]
		if i == 0 {
			min = pi
		} else if min > pi {
			min = pi
		}

		if min == pi {
			r++
		}

	}
	fmt.Printf("%d", r)
}


func splitAndAtoi(s string) []int {
	ss := strings.Split(s, " ")
	var r []int
	for _, s := range ss {
		i, _ := strconv.Atoi(s)
		r = append(r, i)
	}

	return r
}

func nextNumber(s *bufio.Scanner) int {
	i, _ := strconv.Atoi(nextLine(s))
	return i
}

func nextLine(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

func debug(s string) {
	fmt.Println(s)
}

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

Measured memory_bytes: 14976
#include <stdio.h>

int main(void)
{
	int N,K,Q;
	scanf("%d %d %d",&N,&K,&Q);
	int i;
	int p[N];
	for(i=1;i<N+1;i++){
		p[i] = 0;
	}
	int A[Q];
	for(i=0;i<Q;i++){
		scanf("%d",&A[i]);
	}
	int j;
	for(i=0;i<Q;i++){
		p[A[i]]++;
	}
	/*
	printf("\n\n\n");
	for(i=1;i<N+1;i++){
		printf("%d\n",p[i]);
	}
	printf("\n\n\n");
	*/
	int b = Q-K+1;
	//printf("b = %d\n",b);
	for(i=1;i<N+1;i++){
		if(p[i]>Q-K)
		{
			printf("Yes\n");
			//printf("p[%d] = %d\n",i,p[i]);
		}
		else{
			printf("No\n");
			//printf("p[%d] = %d\n",i,p[i]);
		}
	}
	//printf("K=%d\n",K);
	return 0;
}




Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(void){
    long long n,a,x[50],d[50][10000];
    cin>>n>>a;
    for(int i=0;i<n;i++){
        cin>>x[i];
        x[i]-=a;
        for(int j=0;j<10000;j++)d[i][j]=0;
    }
    d[0][5000]++;
    d[0][x[0]+5000]++;
    for(int i=1;i<n;i++){
        for(int j=-4000;j<4000;j++){
            d[i][j+5000]=d[i-1][j+5000]+d[i-1][j-x[i]+5000];
        }
    }
    cout<<d[n-1][5000]-1<<endl;
}


Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    String str = scan.nextLine();

    for (int i = 0; i < str.length(); i++) {
      char ch = str.charAt(i);
      if(Character.isUpperCase(ch)) {
        System.out.print(Character.toLowerCase(ch));
      } else if(Character.isLowerCase(ch)) {
        System.out.print(Character.toUpperCase(ch));
      } else {
        System.out.print(ch);
      }
    }
    System.out.println();

  }

}


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

using namespace std;

int main(){
    string s,t,u;
    cin >> s >> t ;
    int a,b;
    cin >> a >> b;
    cin >> u;
    int su,tu;
    su=s.compare(u);
    tu=t.compare(u);
    if(su==0){
        a--;
    }
    else{
        b--;
    }
    cout << a <<" " <<  b << endl;

}

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

int f(long long x){
  int res = 0;
  while (x){
    res += x%10;
    x/=10;
  }
  return res;
}

int main() {
  long long n;
  cin>>n;
  cout<<(n%f(n)?"No":"Yes")<<endl;
}


Measured memory_bytes: 256
//
// Created by 田代真生 on 2019-10-02.
//
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

string S;
long len_s;

long dfs(long ind, long last, long sum){
    if(ind == len_s) {
        return sum + last;
    } else {
        return dfs(ind + 1, (stol)(to_string(last) + S[ind]), sum) + dfs(ind + 1, 0, sum + last);
    }
}
int main(){
    cin >> S;
    len_s = S.size();
    cout << dfs(0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
//#include <c++/algorithm>

using namespace std;

bool is_palindrom(string s,int i,int n) {
    for(i=0; i<n; i++) {
        if(s[i]!=s[n-1-i]) {
            return false;
        }
    }
    return true;
}

int main() {

    string s;
    cin >> s;

    int n = s.length();

    if(is_palindrom(s,0,n)&&is_palindrom(s,0,(n-1)/2)&&is_palindrom(s,(n+3)/2,n))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

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

int main(){
    int h,n;
    cin >> h >> n;
    vector <int> a(n),b(n);
    rep(i,n){
        cin >> a[i] >> b[i]; 
    }
    vector <vector <int>> ans(n,vector <int> (h+1));

    rep(i,h+1){
        if(i==0){
            ans[0][i]=b[0];
        }
        else{
        ans[0][i]=((i-1)/a[0]+1)*b[0];
        }
    }

    rep(i,n-1){
        rep(j,h+1){
            if(j<=a[i+1]){
                ans[i+1][j]=min(ans[i][j],b[i+1]);
            }
            else{
                ans[i+1][j]=min(ans[i+1][j-a[i+1]]+b[i+1],ans[i][j]);
            }
            //cout << ans[i][j] << endl;
        }
        
    }

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

    

    return 0;
}

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

struct edge {
    int from, to;
    int cost;
};

struct vert {
    vector<edge> edges;
};

bool bellmanford(
        const vector<vert>& verts,
        int initPoint,
        vector<long long>& dist,
        vector<int>& prev
        ) {
    for (int i = 0; i < dist.size(); ++i) {
        dist[i] = LONG_LONG_MAX;
    }
    dist[initPoint] = 0;
    prev[initPoint] = initPoint;

    bool updated = false;
    for (int i = 0; i < verts.size(); ++i) {
        updated = false;
        for (const auto& v : verts) {
            for (const auto& e : v.edges) {
                if (dist[e.from] == LONG_LONG_MAX) continue;
                if (dist[e.from] + e.cost >= dist[e.to]) continue;
                dist[e.to] = dist[e.from] + e.cost;
                prev[e.to] = prev[e.from];
                updated = true;
            }
        }
    }
    return !updated;
}

int main() {
    int V, E, r;
    cin >> V >> E >> r;
    vector<vert> verts(V);
    vector<long long> dist(V);
    vector<int> prev(V);
    for (int i = 0; i < E; ++i) {
        edge e;
        cin >> e.from >> e.to >> e.cost;
        verts[e.from].edges.push_back(e);
    }
    bool negative_cycle = !bellmanford(verts, r, dist, prev);
    if (negative_cycle) {
        cout << "NEGATIVE CYCLE" << endl;
    } else {
        for (int i = 0; i < V; ++i) {
            if (dist[i] == LONG_LONG_MAX) {
                cout << "INF" << endl;
            } else {
                cout << dist[i] << endl;
            }
        }
    }
}



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

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



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

using namespace std;

int main() {
    int n,k,result=0;
    cin>>n>>k;
    int p[n];
    for(int i=0;i<n;i++) cin>>p[i];
    for(int i=0;i<k;i++) {
        int small = INT_MAX;
        int k=0;
        for(int j=0;j<n;j++) {
            if(p[j]<small) {
                small=p[j];
                k=j;
            }
        }
        result+=small;
        p[k]=INT_MAX;
    }
    cout<<result<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string base[]={"dream","dreamer","erase","eraser"},s;
  cin>>s;
  int ss=s.size();
  while(s.size()){
    bool f=1;
    for(int i=0;i<4;i++){
      if(ss<base[i].size()) continue;
      if(s.substr(ss-base[i].size(),base[i].size())==base[i]){
	ss-=base[i].size();
	f=0;
	break;
      }
    }
    if(f) break;
  }
  cout << (ss?"NO":"YES") << endl;
  return 0;
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
//const int inf = 1e9; //1(1倍)e(指数)9(10^9)
//const ll MX = 1e18; //1(1倍)e(指数)18(10^18)
//const ll MOD = 1e9 + 7; //1000000007で割った余りを聞かれたら使う
//加算代入演算子は+=
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
//10^10くらいまででdoubleは誤差が発生しちゃう。なるべく整数にすること
//doubleからlong longにキャストするときは、+0.5で切り捨ての誤差を調整
//__int128()で128bit対応の整数（多倍長整数）
//||は片方が成り立つとき
int main()
{
    string s;
    cin >> s;
    int count = 0;
    rep(i, s.size())
    {
        rep(j, s.size())
        {
            if (s[i] == s[j])
            {
                count++;
            }
        }
    }
    if (count > s.size())
        cout << "no" << endl;
    else
        cout << "yes" << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s == "SUN") cout << 7 << endl;
  else if (s == "MON") cout << 6 << endl;
  else if (s == "TUE") cout << 5 << endl;
  else if (s == "WED") cout << 4 << endl;
  else if (s == "THU") cout << 3 << endl;
  else if (s == "FRI") cout << 2 << endl;
  else if (s == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 3010;
const int MAXM = 1000010;
const int MAXK = 110;
const int MAXQ = 200010;

int n;
ll dp[MAXN][MAXN];
string s;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    cin >> s;
    s = "  " + s;
    FOR(i,1,n) dp[1][n-i] = 1;
    FOR(i,1,n-1) {
        int remain = n-i;
        FOR(j,0,remain)
            if (s[i+1] == '<') {
                dp[i+1][0] = (dp[i+1][0] + dp[i][j]) % MODBASE;
                dp[i+1][j] = (dp[i+1][j] - dp[i][j] + MODBASE) % MODBASE;
            }
            else {
                dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MODBASE;
                dp[i+1][remain] = (dp[i+1][remain] - dp[i][j] + MODBASE) % MODBASE;
            }
        FOR(j,1,remain-1) dp[i+1][j] = (dp[i+1][j-1] + dp[i+1][j]) % MODBASE;
    }
    cout << dp[n][0];
    return 0;
}


Measured memory_bytes: 70016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 2e5+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    bool f=false;
    for(int i=1;i<=100;i++){
        if((i*a)%b==c){
            f=f|true;
        }
    }
    if(f)cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#define MAX 200001
using namespace std;
typedef long long ll;

int main()
{
	int n, res = 0;
	cin >> n;
	while (n--) {
		int a;
		cin >> a;
		res += a - 1;
	}
	cout << res;
	return 0;
}

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

const ll MOD = 998244353LL;

class ModuloCombination {
private:
  vector<ll> fact, fact_inv;

  static ll mod_pow(ll a, ll n) {
    if(n == 0) return 1;
    if(n % 2 == 0) return mod_pow((a * a) % MOD, n / 2);
    return (a * mod_pow(a, n - 1)) % MOD;
  }

public:
  ModuloCombination(ll N): fact(N + 1), fact_inv(N + 1) {
    fact[0] = 1;
    REP(i, 1, N + 1) fact[i] = (i * fact[i - 1]) % MOD;
    REP(i, 0, N + 1) fact_inv[i] = mod_pow(fact[i], MOD - 2);
  }

  ll operator()(ll n, ll r) {
    return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
  }
};

int main(void) {
  ll N, A, B, K;
  cin >> N >> A >> B >> K;

  ModuloCombination C(N);
  ll ans = 0;

  REP(x, 0, N + 1) {
    if(K - x * A >= 0 && (K - x * A) % B == 0) {
      ll y = (K - x * A) / B;
      if(!(0 <= y && y <= N)) continue;
      ans = (ans + C(N, x) * C(N, y) % MOD) % MOD;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int dp[N];
int a[N];
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(i==1)    continue;
        dp[i] = 1e9;
        for(int j=i-1;j>=i-k&&j>=1;j--)   dp[i] = min(dp[i],dp[j]+abs(a[i]-a[j]));
    }
    printf("%d\n",dp[n]);
    return 0;
}


Measured memory_bytes: 1024
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, a, b = na()

ans = (n - 2) * b - (n - 2) * a + 1
if ans <= 0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

double table[100][100];

double dp[100][100][100]; // dp[times][cur][prev]

signed main()
{
	int N, M;
	
	while (cin >> N >> M, N || M) {
		memset(dp, 0, sizeof(dp));

		rep(i, N) rep(j, N) cin >> table[i][j];

		rep(i, N) rep(j, N) dp[0][i][j] = 1.0;

		for (int i = 1; i < M; ++i) {
			for (int j = 0; j < N; ++j) {
				for (int k = 0; k < N; ++k) {
					dp[i][j][k] = max(dp[i][j][k], *max_element(dp[i - 1][k], dp[i - 1][k] + N) * table[k][j]);
				}
			}
		}

		double ans = 0;

		rep(i, 100) rep(j, 100) ans = max(ans, dp[M - 1][i][j]);

		printf("%.2f\n", ans);
	}
}

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  int q;
  cin >> q;
  rep(qi, q)
  {
    int b, m, e;
    cin >> b >> m >> e;
    rotate(a.begin() + b, a.begin() + m, a.begin() + e);
  }
  rep(i, a.size()) cout << a[i] << (i == a.size() - 1 ? "\n" : " ");
  return 0;
}



Measured memory_bytes: 3212
while True:
    S = input()
    if S == "#":
        break

    a, b, c, d = map(int, input().split())

    hasBall = [[False for _ in range(10)] for _ in range(10)]

    rows = S.split('/')
    H = len(rows)
    for h, row in enumerate(rows, start=1):
        cur = 1
        colsize = 0
        for ch in row:
            if ch == 'b':
                hasBall[h][cur] = True
                colsize += 1
                cur += 1
            else:
                colsize += int(ch)
                cur += int(ch)
        W = colsize

    # for h in range(H+2):
    #     for w in range(W+2):
    #         print(hasBall[h][w], end="")
    #     print()

    hasBall[a][b] = False
    hasBall[c][d] = True

    rows = []
    for h in range(1, H+1):
        streak = 0
        row = ""
        for w in range(1, W+1):
            if hasBall[h][w]:
                if streak:
                    row += str(streak)
                    streak = 0
                row += 'b'
            else:
                streak += 1
        if streak:
            row += str(streak)

        rows.append(row)

    # for h in range(H+2):
    #     for w in range(W+2):
    #         print(hasBall[h][w], end="")
    #     print()

    print("/".join(rows))



Measured memory_bytes: 5608
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  // string A;
  // cin >> A;
  // double B;
  // cin >> B;
  // int B_100 = (int)(B * 100);
  // if (A == "0") {
  //   cout << 0 << endl;
  //   return 0;
  // }

  // if (A.size() <= 2) {
  //   int A_i = stoi(A);
  //   int A_100 = A_i * 100;
  //   int tmp = B_100 * A_100;
  //   int ans = tmp / 10000;
  //   cout << ans << endl;
  //   return 0;
  // }

  // int A_2dig = (A[A.size() - 1] - '0') + (A[A.size() - 2] - '0') * 10;
  // int A_2dig_100 = A_2dig * 100;
  // // cout << A_2dig_100 << endl;
  // int tmp = B_100 * A_2dig_100;
  // int ans_2dig = tmp / 10000;
  // A[A.size() - 1] = '0';
  // A[A.size() - 2] = '0';
  // ll A_ll = stoll(A);
  // ll A_ll_100 = A_ll / 100;
  // ll ans = A_ll_100 * B_100;
  // ans = ans / 100;
  // ans = ans * 100;

  // cout << A_ll_100 << endl;
  // cout << B_100 << endl;

  // cout << ans << endl;
  // cout << ans_2dig << endl;
  // cout << ans + ans_2dig << endl;
  long long A;
  long double B;
  cin >> A >> B;
  ll ans = floorl(A * B);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3764
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout);
using namespace std;
const int MAXN = 300010;
int W, H, n, m;
int L, R, _max[MAXN << 2], lazy[MAXN << 2];
int sta1[MAXN], sta2[MAXN], top1, top2;
int a[MAXN];
int ans;

struct like {
    int x, y;
    bool operator < (const like &r) const {
        return x < r.x || (x == r.x && y < r.y);
    }
} s[MAXN], A[MAXN];

void update(const int &o, const int &ls, const int &rs) {
    _max[o] = max(_max[ls], _max[rs]);
}

void build(int o, int l, int r) {
    lazy[o] = 0;
    if (l == r) {
        _max[o] = -a[l];
        return;
    }
    int ls = o << 1, rs = ls | 1, mid = (l + r) >> 1;
    build(ls, l, mid), build(rs, mid + 1, r);
    update(o, ls, rs);
}

void pushdown(const int &o, const int &ls, const int &rs) {
    _max[ls] += lazy[o], lazy[ls] += lazy[o];
    _max[rs] += lazy[o], lazy[rs] += lazy[o];
    lazy[o] = 0;
}

void modify(int o, int l, int r, int v) {
    if (L <= l && r <= R) {
        lazy[o] += v, _max[o] += v;
        return;
    }
    int ls = o << 1, rs = ls | 1, mid = (l + r) >> 1;
    if (lazy[o])
        pushdown(o, ls, rs);
    if (L <= mid)
        modify(ls, l, mid, v);
    if (R > mid)
        modify(rs, mid + 1, r, v);
    update(o, ls, rs);
}

void solve(int n) {
    int mid = H >> 1;
    for (int i = 1; i <= n; i++)
        A[i] = s[i];
    sort(A + 1, A + n + 1);
    if (A[n].x < W)
        A[++n] = (like){W, 0};
    for (int i = 1; i <= n; i++)
        a[i + 1] = A[i].x;
    a[m = n + 2] = W;
    sort(a + 1, a + m + 1), m = unique(a + 1, a + m + 1) - a - 1;
    for (int i = 1; i <= n; i++)
        A[i].x = lower_bound(a + 1, a + m + 1, A[i].x) - a;
    build(1, 1, m);
    top1 = top2 = 0;
    if (A[1].x > 1)
        L = 1, R = 1, modify(1, 1, m, H);
    A[0].x = 1;
    for (int i = 1; i <= n; i++) {
        L = A[i].x, R = A[i].x, modify(1, 1, m, H);
        ans = max(ans, (_max[1] + a[A[i].x]) << 1);
        if (A[i].y <= mid) {
            if ((L = A[sta1[top1]].x) <= (R = A[i].x - 1))
                modify(1, 1, m, -A[i].y);
            while (top1 && A[i].y >= A[sta1[top1]].y) {
                if ((L = A[sta1[top1 - 1]].x) <= (R = A[sta1[top1]].x - 1))
                    modify(1, 1, m, A[sta1[top1]].y - A[i].y);
                top1--;
            }
            sta1[++top1] = i;
        } else {
            if ((L = A[sta2[top2]].x) <= (R = A[i].x - 1))
                modify(1, 1, m, A[i].y - H);
            while (top2 && A[i].y <= A[sta2[top2]].y) {
                if ((L = A[sta2[top2 - 1]].x) <= (R = A[sta2[top2]].x - 1))
                    modify(1, 1, m, A[i].y - A[sta2[top2]].y);
                top2--;
            }
            sta2[++top2] = i;
        }
    }
}

int main() {
    scanf("%d %d %d", &W, &H, &n);
    for (int i = 1; i <= n; i++)
        scanf("%d %d", &s[i].x, &s[i].y);
    solve(n);
    for (int i = 1; i <= n; i++)
        swap(s[i].x, s[i].y);
    swap(W, H);
    solve(n);
    printf("%d", ans);
    return 0;
}


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

int main()
{
	int n;
	vector<int> a;

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

	vector<int> b;
	b.resize( n );
	int center = n / 2;
	int j = 0;
	int sign = 1;
	if( n % 2 ) {
		sign = -1;
	}
	for( int i = 0; i < n; i++ ) {
		b[center + j * sign] = a[i];
		if( i % 2 == 0 ) {
			j++;
		}
		sign *= -1;
	}

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

	return 0;
}


Measured memory_bytes: 3712
N = int(input())
nums= list(map(int,input().split(" ")))
nums.sort()
temp = nums[0]
cleared = nums[0]
for i in range(1,N ):
    if temp * 2 >= nums[i]:
        pass
    else:
        cleared = nums[i]
    temp += nums[i]
ans = 0
for temp in nums:
    if temp >= cleared:
        ans += 1
print(ans)



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

int n,prime[100005],tot,ans;

bool flag[100005];

ll a[100005],b[100005];

map<ll,int>cnt;
map<ll,bool>vis;

int main(){
	for(int i=2;i<2156;i++){
		if(!flag[i]) prime[++tot]=i;
		for(int j=1;j<=tot&&(ll)i*prime[j]<2156;j++){
			flag[i*prime[j]]=1;
			if(i%prime[j]==0) break;
		}
	}
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",a+i);
		ll x=a[i];a[i]=b[i]=1;
		for(int j=2;j<2156;j++){//3√10^10=2154....
			if(x==1) break;
			if(flag[j]) continue;
			ll tmp=(ll)j*j*j;
			while(x%tmp==0) x/=tmp;
			tmp=(ll)j*j;
			if(x%tmp==0) a[i]*=tmp,b[i]*=j;
			else if(x%j==0) a[i]*=j,b[i]*=tmp;
			while(x%j==0) x/=j;
		}
		if(x>1){
			ll tmp=sqrt(x);
			if(tmp*tmp==x) a[i]*=x,b[i]*=tmp;
			else a[i]*=x,b[i]*=x*x;
		}
		cnt[a[i]]++;
	}
	for(int i=1;i<=n;i++) if(!vis[a[i]]){
		vis[a[i]]=1;
		if(a[i]==b[i]) ans++;
		else ans+=max(cnt[a[i]],cnt[b[i]]),vis[b[i]]=1;
	}
	printf("%d",ans);
}

Measured memory_bytes: 26880
#include <iostream>
#include <unordered_set>

using namespace std;
const int POINT_SIZE = 3000;

long toPoint(int x, int y) {
  return (long)(x + y) * (x + y + 1) / 2 + y;
}

long checkSquare(int aX, int aY, int bX, int bY, unordered_set<long> &pointSet) {
  int diffX = abs(aX - bX);
  int diffY = abs(aY - bY);
  bool found = false;

  long point1, point2;
  unordered_set<long>::const_iterator iter1, iter2;
  
  if (aY - diffX >= 0 && bY - diffX >= 0) {
    point1 = toPoint(aX + diffY, aY - diffX);
    point2 = toPoint(bX + diffY, bY - diffX);
    iter1 = pointSet.find(point1);
    iter2 = pointSet.find(point2);

    if (iter1 != pointSet.end() && iter2 != pointSet.end()) {
      return (long)diffX * diffX + (long)diffY * diffY;
    }
  }

  if (aX - diffY >= 0 && bX - diffY >= 0) {
    point1 = toPoint(aX - diffY, aY + diffX);
    point2 = toPoint(bX - diffY, bY + diffX);
    iter1 = pointSet.find(point1);
    iter2 = pointSet.find(point2);

    if (iter1 != pointSet.end() && iter2 != pointSet.end()) {
      return (long)diffX * diffX + (long)diffY * diffY;
    }
  }

  return 0;
}

long calc(int *xArr, int *yArr, unordered_set<long> &pointSet, int count) {
  long maxArea = 0, area;

  for (int i = 0; i < count; i++) {
    for (int j = i + 1; j < count; j++) {
      area = checkSquare(xArr[i], yArr[i], xArr[j], yArr[j], pointSet);
      if (maxArea < area) {
        maxArea = area;
      }
    }
  }

  return maxArea;
}

int main(int argc, char const* argv[])
{
  int count, x, y;

  while (true) {
    cin >> count;
    if (count == 0) break;

    int xArr[count], yArr[count];
    unordered_set<long> pointSet;

    for (int i = 0; i < count; i++) {
      cin >> x >> y;

      xArr[i] = x;
      yArr[i] = y;
      pointSet.insert(toPoint(x, y));
    }

    cout << calc(xArr, yArr, pointSet, count) << endl;
  }
  return 0;
}

Measured memory_bytes: 1356
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_11_B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            List<int> s;

            int partialSet = 0;    
            foreach (var x in ReadIntAr().Skip(1)) partialSet |= (1 << x);

            for (int i = 0 ; i < (1 << n) ; i++)
            {
                s = new List<int>(n);
                for (int j = 0 ; j < n ; j++)
                {
                    if ((i >> j & 1) == 1) s.Add(j);
                }

                if ((i & partialSet) == partialSet)
                {
                    Console.WriteLine("{0}:{1}", i, (s.Count == 0 ? "" : " ") + string.Join(" ", s.Select(x => x.ToString()).ToArray()));
                }
                
            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



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


int main(){
    int a,b,c;cin>>a>>b>>c;
    int counter=0;
    if((a==b)&&(b==c)){
        counter=1;
    }
    else if((a==b)||(b==c)||(c==a)){
        counter=2;
    }
    else{
        counter=3;
    }
    cout<<counter<<endl;
    return 0; 
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i,height,one = 0,two = 0,three = 0;
    for(i=0;i<10;++i){
        scanf("%d",&height);
        if(one < height){
            three = two;
            two = one;
            one = height;
        }else if(two < height){
            three = two;
            two = height;
        }else if(three <= height){
            three = height;
        }
    }
    printf("%d\n%d\n%d\n",one,two,three);
}

Measured memory_bytes: 1028
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;

const int MOD = 1000000007;
const int INF = 1000000000;

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

int main(){
    int n; cin >> n;
    set<string> st;
    bool okay = true;
    char prv;
    REP(i, n){
        string s; cin >> s;
        if(i){
            if(prv != s[0]) okay = false;
            if(st.find(s) != st.end()) okay = false;
        }
        st.insert(s);
        prv = s[s.length()-1];
    }
    cout << (okay ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 256