akhauriyash/Code-Regression huggingface dataset:
<?php
	$answer = [0, 0, 0, 0];
	while($array = explode(" ", trim(fgets(STDIN)))){
		sort($array);
		$min = $array[0];
		$midi = $array[1];
		$max = $array[2];

		if($max >= $midi + $min){
			break;
		}
		if($max**2 === $min**2 + $midi**2){
			$answer[1] +=1;
		}elseif ($max**2 < $min**2 + $midi**2) {
			$answer[2] +=1;
		}else{
			$answer[3]+=1;
		}
		$answer[0] += 1;

	};

	echo implode(" ", $answer);
	echo "\n";

?>


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

using namespace std;

bool bad[11];

bool check(int x) {
  while(x > 0) {
    if(bad[x % 10]) return false;
    x /= 10;
  }
  return true;
}

int main() {
  int n, k; cin >> n >> k;
  for(int i = 0; i < k; i++) {
    int x; cin >> x;
    bad[x] = 1;
  }
  while(true) {
    if(check(n)) {
      return !printf("%d\n", n);
    }
    n = n + 1;
  }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BHomework solver = new BHomework();
        solver.solve(1, in, out);
        out.close();
    }

    static class BHomework {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int acc = 0;
            for (int i = 0; i < m; i++) {
                acc += in.nextInt();
            }
            out.println(n < acc ? -1 : n - acc);
        }

    }
}



Measured memory_bytes: 46468
#include <iostream>
#include <set>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>
typedef long long ll;

using namespace std;

signed main(){
  int n, m;
  cin >> n >> m;

  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include <algorithm>
#include<time.h>
#include <numeric>
#include <vector> 
#include <functional>
#include <list>
#include <ctype.h>
#include<map>
#include <set>
#define N 105
using namespace std;
int main(){
	int l,r,d,c=0;
	scanf("%d %d %d",&l,&r,&d);
	for(int i=l;i<=r;i++){
		if(i%d==0)  c++;
	}
	printf("%d",c);
}

Measured memory_bytes: 3808
#include<stdio.h>

//更新書き換え型
int MAX(int *num,int n,int k){
	int i,now,max = 0;
	for(i = 0;i < k;i++){
		max += num[i];
	}
	now = max;
	for(i = 0;i < n-k;i++){
		now += num[i+k]-num[i];
		if(max < now)
			max = now;
	}
	return max;
}
int main(){
	int n,k,max;
	int *num;
	int i;
	while(1){
		scanf("%d%d",&n,&k);
		if(n == 0 && k == 0)
			break;
		num = new int[n];
		for(i = 0;i < n;i++){
			scanf("%d",num+i);
		}
		max = MAX(num,n,k);
		printf("%d\n",max);
		delete[] num;
	}
	return 0;
}

Measured memory_bytes: 1268
using System;
using System.Collections.Generic;
using System.Linq;

class D
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var js = new int[h[0]].Select(_ => read()).Where(j => j[0] <= h[1]).GroupBy(j => j[0]).ToDictionary(g => g.Key, g => g.ToArray());

		var r = 0L;
		var l = new List<int>();
		for (var i = 1; i <= h[1]; i++)
		{
			if (js.ContainsKey(i))
				foreach (var j in js[i])
				{
					var k = l.BinarySearch(j[1]);
					if (k < 0) k = ~k;
					l.Insert(k, j[1]);
				}

			if (!l.Any()) continue;
			r += l.Last();
			l.RemoveAt(l.Count - 1);
		}
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 43304
#include <stdio.h>

int stack[1000],point=0;


int fstack(int com,int num){
	int data;
	if(com==0){
		data=stack[point];
		stack[point]=num;
		point--;
		return data;
	}
	if(com==1){
		point++;
		stack[point]=num;
		return 0;
	}else{
		return -1;
	}
}

int main(){
	int a;

	while(scanf("%d",&a)!=EOF){
		if(a==0){
			a=fstack(0,0);
			printf("%d\n",a);
		}else{
			fstack(1,a);
		}
	}

	return 0;
}

Measured memory_bytes: 600
n = int(input())
m2 = []

if n == 0:
    print(0)
    
while n != 0:
    if n % -2 != 0:
        m2.append('1')
        n = n // -2 + 1
    else:
        m2.append('0')
        n = n // -2
        
m2.reverse()
print(''.join(map(str, m2)))

Measured memory_bytes: 3060
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
S=input()
white = [0] * (N+1)
black = [0] * (N+1)
for i in range(N):
    if S[N-1-i] == '.':
        white[i] = white[i-1] + 1
    else:
        white[i] = white[i-1]
    if S[i] == '#':
        black[i] = black[i-1] + 1
    else:
        black[i] = black[i-1]
ans = black[-1] + white[N-1]
for i in range(N):
    ans = min(ans, black[i] + white[N-2-i])
print(ans)

Measured memory_bytes: 12832
/*
  AOJ 2049
  Title:Headstrong Student
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

int table[1000001];

main()
{
  int x,y,c,r,pos;

  while(scanf("%d %d",&x,&y) && (x||y))
    {
      memset(table,-1,sizeof(table));
      c=0;
      while(1)
	{
	  if(table[x] != -1)
	    {
	      if(x==0)
		printf("%d 0\n",c-1);
	      else
		printf("%d %d\n",table[x],c-table[x]);
	      break;
	    }
	  table[x]=c;
	  x *= 10;
	  x %= y;
	  c++;
	}
    } 	
    
  return(0);
}

Measured memory_bytes: 4512
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let numbers: Vec<i32> = read_vec();
    let mut result: i32 = 0;

    result = numbers[0] - (numbers[1] * 2);
    if result < 0 { result = 0; }

    println!("{}", result);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    ll N, M;
    scan(N, M);
    set<ll> ac;
    map<ll, ll> wa;
    ll ans_ac = 0, ans_wa = 0;
    set<ll> end;
    rep(i, M) {
        ll p;
        string s;
        scan(p, s);
        if (s == "AC" && ac.count(p) == 0) {
            ac.insert(p);
            if (0 < wa.count(p)) {
                ans_wa += wa[p];
            }
        } else if (s == "WA" && ac.count(p) == 0) {
            if (wa.count(p) == 0)
                wa[p] = 1;
            else
                wa[p]++;
        }
    }
    ans_ac = ac.size();
    print(ans_ac, ans_wa);

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(all(a));
  if (a[0]+a[1]==a[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using vi = std::vector<int>;

class Matching
{
public:
	std::vector<vi> edge;
	std::vector<bool> visited;

	void add_edge(const int from, const int to)
	{
		edge[from][to] = 1;
	}

	int dfs(const int index, const int sink, const int flow)
	{
		if (index == sink)
			return flow;
		visited[index] = true;
		for (unsigned int next{}; next < edge.size(); next++)
		{
			if (visited[next] || !edge[index][next])
				continue;
			int ret{dfs(next, sink, std::min(flow, edge[index][next]))};
			if (ret == 0)
				continue;
			edge[index][next] -= ret;
			edge[next][index] += ret;
			return ret;
		}
		return 0;
	}

	int max_flow(const int source, const int sink)
	{
		int flow_sum{};
		while (true)
		{
			std::fill(visited.begin(), visited.end(), false);
			const int flow{dfs(source, sink, 1 << 30)};
			if (flow == 0)
				return flow_sum;
			flow_sum += flow;
		}
		return -1;
	}
};

int gcd(int a, int b)
{
	while (a)
	{
		b %= a;
		std::swap(a, b);
	}
	return b;
}

int main()
{
	while (true)
	{
		int m, n;
		scanf("%d%d", &m, &n);
		if (m == 0 && n == 0) break;

		std::vector<int> blue(m), red(n);
		for (auto &e : blue)
			scanf("%d", &e);
		for (auto &e : red)
			scanf("%d", &e);

		Matching mt;
		mt.edge.resize(n + m + 2, vi(n + m + 2));
		for (int i{}; i < m; i++)
			mt.add_edge(n + m, i);
		for (int i{}; i < n; i++)
			mt.add_edge(m + i, n + m + 1);
		for (int i{}; i < m; i++)
		{
			for (int j{}; j < n; j++)
			{
				if (gcd(blue[i], red[j]) != 1)
				{
					mt.add_edge(i, m + j);
				}
			}
		}

		mt.visited.resize(m + n + 2);
		printf("%d\n", mt.max_flow(n + m, n + m + 1));
	}

	return 0;
}


Measured memory_bytes: 6816
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i=0; i<h; ++i)
        cin >> s[i];

    vector<vector<int> > dp(h, vector<int>(w, 0));
    dp[0][0] = 1;
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            if(s[y][x] == '#')
                continue;

            if(y < h - 1){
                dp[y+1][x] += dp[y][x];
                dp[y+1][x] %= MOD;
            }
            if(x < w - 1){
                dp[y][x+1] += dp[y][x];
                dp[y][x+1] %= MOD;
            }
        }
    }
    cout << dp[h-1][w-1] << endl;

    return 0;
}


Measured memory_bytes: 5248
class Entry
  attr_reader :size, :value
 
  def initialize(size, value)
    @size = size
    @value = value
  end
end
 
class PrefixQueue
  def initialize
    @list = []
    @prefix = ''
  end
 
  def empty?
    @list.empty?
  end
 
  def shift
    entry = @list.shift
    [@prefix[0...entry.size], entry.value]
  end
 
  def push(key, value)
    (0...@list.size).each do |i|
      entry = @list[i]
      target = @prefix[0...entry.size]
      case target <=> key
      when -1
        return nil unless key.start_with?(target)
      when 0
        return entry.value
      else
        if target.start_with?(key)
          @list.insert(i, nil)
        else
          @prefix = key
          @list.slice!(i+1..-1)
        end
        @list[i] = Entry.new(key.size, value)
        return value
      end
    end
    @prefix = key
    @list << Entry.new(key.size, value)
    return value
  end
end

class Arrow
  attr_reader :source, :sink, :label

  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end

def collect(n, arrows, goal)
  come_from = Array.new(n){[]}
  arrows.each do |arrow|
    come_from[arrow.sink] << arrow.source
  end

  reachable_from = [false] * n
  stack = [goal]
  until stack.empty?
    node = stack.pop
    reachable_from[node] = true
    come_from[node].each do |source|
      stack << source unless reachable_from[source]
    end
  end
  reachable_from
end

def work(n, arrows, start, goal)
  reachable_from = collect(n, arrows, goal)
  return nil unless reachable_from[start]

  go = Array.new(n){[]}
  arrows.each do |arrow|
    go[arrow.source] << arrow if reachable_from[arrow.sink]
  end

  queue = PrefixQueue.new
  queue.push('', {start => true})
  until queue.empty?
    spell, map = queue.shift
    return spell if map[goal]

    return nil if spell.size > 500

    map.each do |node, tainted|
      go[node].each do |arrow|
        t = queue.push(spell + arrow.label, {})
        t[arrow.sink] = true if t
      end
    end
  end
  nil
end

loop do
  n, a, s, g = gets.split.map(&:to_i)
  break if n == 0

  arrows = (0...a).map do |i|
    x, y, lab = gets.split
    Arrow.new(x.to_i, y.to_i, lab)
  end

  puts work(n, arrows, s, g) || 'NO'
end

Measured memory_bytes: 12568
using System;

class ABC_163_C
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] ans = new int[N];

        for (int i = 0; i < N-1; i++)
        {
            int p = int.Parse(input[i]);
            ans[p-1]++; 
        }

        for (int i = 0; i < N; i++)
        {
        	Console.WriteLine(ans[i]);
        }

	}
}


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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int X;
        cin >>X;
        if (X>=30)
                cout <<"Yes" <<endl;
        else
                cout <<"No" <<endl;
        return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
  int n;
  string s;
  cin >>n>>s;
  
 ll sr=0,sg=0,sb=0;

  for(int i=0; i<s.size(); i++){
    if(s.at(i)=='R'){sr++;}
    else if(s.at(i)=='G'){sg++;}
    else if(s.at(i)=='B'){sb++;}  
  }
//  cout<<sr<<" "<<sg<<" "<<sb<<endl;;

  ll all= sr*sg*sb;
  ll exclude=0;
  //set<char> rgb{'R','B','G'};

  for(int i=0; i<n; i++){
    for(int j=i+1; j<n ; j++){
      if(2*j-i<n) {
        int k=2*j-i;
      //else{continue;}
     // set<char> num{s.at(i),s.at(j),s.at(k)};
        if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k])
          exclude++;
      }
    }
  }
  
  cout<< all-exclude;
  }
 







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

int main() {
	int n;
	string s;
	cin >> n >> s;
	if (n % 2 == 0 && s.substr(0, n / 2) == s.substr(n / 2)) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256
var a,b,c:longint;
begin
readln(a,b,c);
writeln(a,' ',b,' ',-a-b+3*c);
writeln(-2*a-b+4*c,' ',c,' ',2*a+b-2*c);
writeln(a+b-c,' ',-b+2*c,' ',-a+2*c);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
/*
int main(){
	int c=0;
	double  a,b,sum=0.0;
	int x[21]={},y[21]={};
	while(scanf("%lf,%lf",&a,&b)!=EOF){
		//if(a==-1) break;
		if(c==0){
			x[c]=a; y[c]=b;
		}else{
			x[c]=a-x[0]; y[c]=b-y[0];
		}
		c++;
	}
	rep(i,1,c-1){
		sum+=0.5*abs(x[i]*y[i+1]-x[i+1]*y[i]);
	}
	printf("%.10lf\n",sum);
}*/
/*
double dist(double x1,double y1,double x2,double y2){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

double solve(double x1,double y1,double x2,double y2,double x3,double y3){
	double a,b,c,z,s;
	a=dist(x1,y1,x2,y2);
	b=dist(x2,y2,x3,y3);
	c=dist(x3,y3,x1,y3);
	z=(a+b+c)*0.5;
	s=sqrt(z*(z-a)*(z-b)*(z-c));
	return s;
}

int main(){
	char c;
	double x1,y1,x2,y2,x3,y3,sum=0;
	cin>>x1>>c>>y1>>x2>>c>>y2;
	//scanf("%lf,%lf%c%lf,%lf",&x1,&y1,&c,&x2,&y2);
	while(scanf("%lf,%lf",&x3,&y3)!=EOF){
		sum+=solve(x1,y1,x2,y2,x3,y3);
		x2=x3; y2=y3;
		o(" "<<sum);
	}
	printf("%.10lf",sum);
}*/

typedef complex<double> xy_t;

//??????????¬?????????¢????????????
double cross_product(xy_t a,xy_t b){
	return (conj(a)*b).imag();
}

xy_t P[110];

int main(){
	int n=0;
	double x,y;
	while(~scanf("%lf,%lf",&x,&y)){
		P[n++]=xy_t(x,y);
	}
	double sum=0.0;
	rep(i,0,n-2){
		xy_t a=P[0],b=P[i+1],c=P[i+2];
		sum+=0.5*cross_product(b-a,c-a);
	}
	printf("%.6lf\n",abs(sum));
}

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

using Graph = vector<vector<int>>;

vector<bool> has_visited;
void DFS(const Graph &G, int v, int depth)
{
    if (2 < depth)
        return;
    has_visited[v] = true;

    for (auto w : G[v])
    {
        if (has_visited[w])
            continue;
        DFS(G, w, depth + 1);
    }
}

int main()
{
    int N, M;
    cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; i++)
    {
        int u, v;
        cin >> u >> v;
        u--, v--;
        G[u].push_back(v);
    }
    has_visited.assign(N, false);
    DFS(G, 0, 0);
    if (has_visited[N - 1])
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[2005][2005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vpll v(n);
  rep(i,n){
    cin>>v[i].first;
    v[i].second=i;
  }
  vsort(v);
  for(ll l=0; l<=n; l++){
    for(ll r=n; r>=l; r--){
      ll idx=r-l;
      if(l>0){
        ll tmp=dp[l-1][r];
        tmp+=abs((l-1)-v[idx].second)*v[idx].first;
        chmax(dp[l][r],tmp);
      }
      if(r<n){
        ll tmp=dp[l][r+1];
        tmp+=abs(r-v[idx].second)*v[idx].first;
        chmax(dp[l][r],tmp);
      }
      // cerr << l << " " << r << " " << idx << " " << dp[l][r] << endl;
    }
  }
  ll ans=0;
  for(ll i=0; i<=n; i++){
    chmax(ans,dp[i][i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 26320
CMD=0
VAL=1
 
class Node
  attr_accessor :value,:left,:right
  def initialize (value)
    @value = value
    @left = nil
    @right = nil
  end
 
  def insert (value)
    if value < @value
      if @left.nil?
        @left = Node.new(value)
      else
        @left.insert(value)
      end
    else
      if @right.nil?
        @right = Node.new(value)
      else
        @right.insert(value)
      end
    end
  end
 
  def find(value)
    if value==@value
      print "yes\n"
    elsif value < @value
      if @left.nil?
        print "no\n"
      else
        @left.find(value)
      end
    else
      if @right.nil?
        print "no\n"
      else
        @right.find(value)
      end
    end
  end
 
 # delete node and return new node 
  def delete(value)
    if value == @value
      if @left.nil? and @right.nil?
        # no child
        return nil
      elsif @left.nil?
        # right child only
        return @right
      elsif @right.nil?
        # left child only
        return @left
      else
        # more than 2 child
        # swap value
        @value = @right.get_new_value
        # delete swapped node
        @right = @right.delete(@value)
        return self
      end
    elsif value < @value
      @left = @left.delete(value)
      return self
    else
      @right = @right.delete(value)
      return self
    end
  end
 
 # find minimum key of subtree
  def get_new_value
    unless @left.nil?
      return @left.get_new_value
    else
      return @value
    end
  end
       
  def print_inorder
    @left.print_inorder unless @left.nil?
    print " #{value}"
    @right.print_inorder unless @right.nil?
  end
   
  def print_preorder
    print " #{value}"
    @left.print_preorder unless @left.nil?
    @right.print_preorder unless @right.nil?
  end
end
 
num_of_cmd = STDIN.gets()
inputs = STDIN.read().split("\n").map{ |input| input.split(' ') }
 
root=nil
inputs.each do |input|
  if input[CMD] == 'insert'
    if root.nil?
      root = Node.new(input[VAL].to_i)
    else
      root.insert(input[VAL].to_i)
    end
  elsif input[CMD] == 'find'
    root.find(input[VAL].to_i)
  elsif input[CMD] == 'delete'
    root.delete(input[VAL].to_i)
  else
    root.print_inorder unless root.nil?
    print "\n"
    root.print_preorder unless root.nil?
    print "\n"
  end
end

Measured memory_bytes: 192024
import java.util.Scanner;
class Main{
public static void main(String[] args){
 Scanner scan = new Scanner(System.in);
 
 int K = scan.nextInt();
 int A = scan.nextInt();
 int B = scan.nextInt();
 int count = 0;
  
  for (int i = 0; i < B-A+1; i++){
  	if ((A + i) % K == 0){
      count += 1;
    }
    else{
    }
  }
  if (count > 0){
  System.out.println("OK");
  }
  if (count == 0){
    System.out.println("NG");
  }
 }
}

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

int main() {
  int N,K;
  cin >> N >> K;
  for(int i=K-N+1 ; i<K+N ; i++){
    if (i==K+N-1){
    cout << i << endl;
    return 0;
    }
    cout << i << " ";
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll n, a, b;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> a >> b;
	vector<ll> h(n);
	for (int i = 0; i < n; i++) 
      cin >> h.at(i);
	ll l = 0, r = 1000000000;
	while(r - l > 1){
		ll mid = (r + l) / 2, sum = 0;
		for (int i = 0; i < n; i++)
			if(h.at(i) > mid * b) 
             	sum += (h.at(i) - mid * b + (a - b - 1)) / (a - b);
		if(sum <= mid) 
          	r = mid;
		else 
          l = mid;
	}
	cout << r << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c,d;
  ll e[4]={};
  cin>>a>>b>>c>>d;
  e[0]=a*c;e[1]=a*d;e[2]=b*c;e[3]=b*d;
  ll p=*max_element(e,e+4);
  cout<<p<<"\n";
    return 0;}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;

namespace agc033_a
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var ins = new Problem();
            ins.solve();
        }
    }

    class Problem
    {
        public void solve()
        {
            Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] v = read();
            int H = v[0];
            int W = v[1];
            int[,] dist = new int[H, W];

            var q = new Queue<Tuple<int, int>> ();

            for (int i = 0; i < H; i++)
            {
                var S = Console.ReadLine().Trim();
                for (int j = 0; j < W; j++)
                {
                    dist[i, j] = -1;
                    if (S[j] == '#')
                    {
                        q.Enqueue(Tuple.Create(j, i));
                        dist[i, j] = 0;
                    }
                }
            }
            var answer = BFS(q, dist, H, W);
            Console.WriteLine(answer);
        }

        public int BFS(Queue<Tuple<int, int>> q, int[,] dist, int h, int w)
        {
            var dx = new int[] { -1, 1, 0, 0 };
            var dy = new int[] { 0, 0, -1, 1 };

            while (q.Count != 0)
            {
                var item = q.Dequeue();
                int x = item.Item1;
                int y = item.Item2;

                for (int i = 0; i < 4;i++)
                {
                    int px = x + dx[i];
                    int py = y + dy[i];
                    if (!(0 <= py && py < h && 0 <= px && px < w))
                    {
                        continue;
                    }
                    if (dist[py, px] == -1)
                    {
                        q.Enqueue(Tuple.Create(px, py));
                        dist[py, px] = dist[y, x] + 1;
                    }
                }

            }
            var ans = 0;
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    ans = Math.Max(ans, dist[i, j]);
                }
            }
            return ans;
        }
    }
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

VI pr;
void eratos (int n){
	vector<bool> prime(n+5); //prime.resize(n+5);
	prime[2] = true; prime[0] = prime[1] = false;
	for(int i = 3; i <= n; i += 2){ prime[i] = true; prime[i+1] = false;}
	int limit = (int)sqrt((double)n) + 1;
	for(int i = 3; i <= limit; i += 2) if(prime[i]) {
		for(int j = i*i; j <= n; j += i+i) prime[j] = false;
	}
	rep(i, n+1) if(prime[i]) pr.push_back(i);
}
map<ll, int> fctm2( ll x ){
	map<ll, int> fmp;
	for(int i=0; (ll)pr[i]*pr[i]<=x; i++){
		for(int pz=pr[i]; x%pz==0 && x>=pz; x/=pz) fmp[pz]++;
	}
	if(x!=1) fmp[x]++;
	return fmp;
}
ll gcd(ll x, ll y){ return y? gcd(y, x%y): x; }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	rep(i, n) cin >>a[i];
	sort(all(a));
	
	eratos(a.back()+100);
	int ok = 1;
	map<ll, int> mp;
	rep(i, n){
		auto uk = fctm2(a[i]);
		for(auto& z: uk){
			mp[z.first]++;
			if(mp[z.first] > 1){ ok =2; break;}
			
		}
		if(ok>1) break;
	}
	
	if(ok==1){ puts("pairwise coprime"); return 0;}
	
	ll g = 0;
	rep(i, n) g = gcd(g, a[i]);
	if(g==1) puts("setwise coprime");
	else puts("not coprime");
	return 0;
}



Measured memory_bytes: 11780
#include<bits/stdc++.h>
using namespace std;
map<int, int> m;
int n;

int main() {
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        int x;scanf("%d", &x);
        m[x]++, ans = max(ans, m[x]);
        m[x + 1]++, ans = max(ans, m[x + 1]);
        m[x - 1]++, ans = max(ans, m[x - 1]);
    }
    cout << ans << endl;
}


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

int main()
{
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i,N){
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  vector<int> d(N);
  int before=0;
  rep(i,N-1){
    d[i+1]=h[i+1]-h[i]+before;
    before=d[i+1];
  }
  // rep(i,N-1) cout << d[i] << " ";
  // cout << endl;
  int ans=1000000000;
  rep(i,N-K+1){
    ans = min(ans,d[i+K-1]-d[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s, t;
	cin >> s >> t;
	int a, b;
	scanf("%d%d", &a, &b);
	string u;
	cin >> u;
	if(u == s) cout << a - 1 << " " << b << endl;
	else cout << a << " " << b - 1 << endl;
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=100000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
typedef pair<int,string> Q;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
//void swap(ll a,ll b){
//	ll d;
//	d=a;
//	a=b;
//	b=d;
//	return;
//}
ll mypow(ll x,int m){
	if(m==0)return 1;
	if(m%2==0){
		int x2=mypow(x,m/2);
		return x2*x2;
	}else{
		int x2=mypow(x,m/2);
		return x2*x2*x;
	}
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
//    	cout<<b<<endl;
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll total=0;
int a[200000],b[200000];
int x[1000]={};
int m1,m2,n1,n2;
int c[10];
int d[10];
string s;
vector<P> v[200001];
int ans=0;
int n;

int main() {
	cin>>n>>s;
	rep(i,0,10){
		c[i]=30005;
		d[i]=-1;
	}
	rep(i,0,n){
		c[s[i]-'0']=min(c[s[i]-'0'],int(i));
		d[s[i]-'0']=max(d[s[i]-'0'],int(i));
	}
//	rep(i,0,10){
//		cout<<c[i]<<" "<<d[i]<<endl;
//	}
	rep(i,1,n-1){
		int g=(s[i]-'0')*10;
		rep(j,0,10){
			rep(k,0,10){
				if(c[j]<i&&d[k]>i){
					g+=j*100+k;
					x[g]++;
					g-=j*100+k;
				}
			}
		}
	}
	rep(i,0,1000){
		if(x[i]){
//			cout<<i<<endl;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
//<(") 
#define ll long long   
using namespace std;
 
typedef pair<ll, ll> ii;
typedef pair<ii, ii> iii;
 
const ll mod = 1e9 + 7;
const ll siz =  2e5 + 10;
const ll base = 32;
const ll MAXX = 1e18;

ll n;
map<ii, ll> cnt;

ll Pow(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	ll sub = Pow(a, b / 2);
	if (b % 2 == 0) {
		return sub * sub % mod;
	}
	return (a * (sub * sub % mod)) % mod;
}

bool check(ii val) {
	return (cnt.find(val) != cnt.end());
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
	cin >> n;
	ll djtmemay = 0;
	for (ll i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		ll g = __gcd(abs(a), abs(b));
		if (ii(a, b) == ii(0LL, 0LL)) {
			djtmemay++;
			continue;
		}
		a /= g; b /= g;
		if (a == 0) {
			b = 1;
		}
		else if (b == 0) {
			a = -1;
		}
		else if (b < 0) {
			a *= -1; b *= -1;
		}
		//cerr << a << ' ' << b << '\n'; 
		cnt[ii(a, b)]++;
	} 
	// for (auto i = cnt.begin(); i != cnt.end(); i++) {
		// cerr << (*i).first.first << ' ' << (*i).first.second << ' ' << (*i).second << '\n';
	// }
	//cerr << "\n\n";
	ll ans = 1;
	for (auto i = cnt.begin(); i != cnt.end(); i++) {
		ll val = (*i).second;
		if (!val) {
			continue;
		}
		bool sub = false;
		ii pos = (*i).first;
		swap(pos.first, pos.second);
		pos.first *= -1;
		if (check(pos) && cnt[pos] > 0) {
			//cerr << "Gei1 : " << ' ' << (*i).first.first << ' ' << (*i).first.second << '\n';
			ll x = cnt[pos];
			ans = (ans * ((Pow(2, val) + Pow(2, x) % mod) - 1) % mod) % mod;
			cnt[pos] = 0;
			//cerr << ans << '\n';
			continue;
		}
		pos = (*i).first;
		swap(pos.first, pos.second);
		pos.second *= -1;	
		if (check(pos) && cnt[pos] > 0) {
			//cerr << "Gei 1: " << ' ' << (*i).first.first << ' ' << (*i).first.second << '\n';
			ll x = cnt[pos];
			ans = (ans * ((Pow(2, val) + Pow(2, x) % mod) - 1) % mod) % mod;
			cnt[pos] = 0;
			//cerr << ans << '\n';
			continue;
		}
		//cerr << "Gei 2: " << ' ' << (*i).first.first << ' ' << (*i).first.second << '\n';
		ans = (ans * Pow(2, val)) % mod;
		//cerr << ans << '\n';
	}
	ans = ((ans - 1) + mod * mod) % mod;
	cout << (ans + djtmemay) % mod << '\n';
	return 0;
} 

Measured memory_bytes: 16076
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll H, N;
  cin >> H >> N;
  vl A(N), B(N);
  REP(i, N) cin >> A[i] >> B[i];
  vl DP(H + 1, llINF);
  DP[0] = 0;

  REP(i, N) {
    FOR(j, 1, 2 + (H / A[i])) {
      if (j * A[i] >= H)
        DP[H] = min(DP[H], B[i] * j);
      else
        DP[j * A[i]] = min(DP[j * A[i]], B[i] * j);
    }
  }
  for (ll i = H - 1; i >= 0; i--) {
    DP[i] = min(DP[i + 1], DP[i]);
  }
  ll ans = llINF;
  REP(i, H) REP(k, H - i + 1) { ans = min(ans, DP[i] + DP[k] + DP[H - i - k]); }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
def calc(k)
    i = 1
    loop do
        i *= 2
        break if k < i
    end
    i - k
end

n = gets.to_i
ns = gets.split.map(&:to_i).sort

hash = Hash.new(0)
ns.each do |i|
    hash[i] += 1
end

ans = 0

(n-1).downto(0) do |i|
    next if hash[ns[i]] <= 0
    hash[ns[i]] -= 1    
    pair = calc(ns[i])
    if hash[pair] > 0
        hash[pair] -= 1
        ans += 1
    end
end
puts ans

Measured memory_bytes: 34412
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
int main(){
  long long a,b;
  string S;
  cin>>a>>b;
  if(0>=a && 0<=b) S="Zero";
  else if(a>0) S="Positive";
  else if((b-a+1)%2==1) S="Negative";
  else S="Positive";
  cout<<S<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(int)(n); i++)
ll ctoi(char c){
  if('0' <= c && c<= '9')return(c-'0');
  return -1;
}
int main() {
  ll a;cin>>a;
  ll p,q,r;
  p=a/100;
  q=(a%100)/10;
  r=a%10;
  string b;cin>>b;
  ll s,t,u; 
  s=ctoi(b.at(0));
  t=ctoi(b.at(2));
  u=ctoi(b.at(3));
 
  cout<<(100*p+10*q+r)*s+(10*p+q)*t+p*u
    +(r*t+q*u+(r*u/10))/10;
}
      




Measured memory_bytes: 3624
#include <iostream>

typedef long long ll;

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

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

    string str;

    cin >> str;

    if(str[0] == 'Y' && str[1] == 'A' && str[2] == 'K' && str[3] == 'I'){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    
    return 0;
}


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

#define ll long long int
#define pb push_back
#define RONALDO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pii pair<int,int>
#define ff first
#define ss second


//LOVE U MESSI && CR7 !!

//MY STAR MICHAEL PHELPS && USAIN BOLT !!

// the question is not how but when???...#DARK

int main()
{
  RONALDO;
  ll n,d,ans=0;
  cin>>n>>d;
  for(ll i=0;i<n;i++)
  {
    ll a,b;
    cin>>a>>b;
    if(sqrt(a*a + b*b)<=d)
      ans++;
  }
  cout<<ans;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int N;
  vector<int> even={2,10,3,9,4,8,6,12};
  vector<int> odd={6,2,10,3,9,4,8,12};
  cin>>N;
  if(N==3){
    cout<<2<<" "<<5<<" "<<63<<endl;
  }
  else if(N%2==1){
    FOR(i,0,N){
      cout<<odd[i%8]+12*(i/8)<<" ";
    }
    cout<<endl;
  }
  else {
    FOR(i,0,N){
      cout<<even[i%8]+12*(i/8)<<" ";
    }
    cout<<endl;
  }

}


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

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

  vector<int> h(n);

  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }

  sort(h.begin(), h.end());

  long long sum = 0;

  for (int i = 0; i < n - k; i++) {
    sum += h.at(i);
  }

  cout << sum;
  return 0;
}


Measured memory_bytes: 1024
def inv(x, mod = 10 ** 9 + 7):
    return pow(x, mod - 2, mod)

mod = 10 ** 9 + 7
N = int(input())
fact = [1]
for i in range(1, N):
    fact.append(fact[-1] * i % mod)
inv_fact = [inv(fact[-1])]
for i in reversed(range(1, N)):
    inv_fact.append(inv_fact[-1] * i % mod)
inv_fact = inv_fact[::-1]

ans = prev = 0
for k in range((N + 1) // 2, N):
    cnt = fact[k - 1] * inv_fact[k * 2 - N] % mod * fact[k] % mod
    ans += (cnt - prev + mod) * k
    ans %= mod
    prev = cnt
print(ans)


Measured memory_bytes: 90776
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		//Scanner????????????????????????
		Scanner scan = new Scanner(System.in);
		//??¶??°???????????????
		int n = scan.nextInt();
		//System.out.println("?????????????????????:" + n);

		//??\?±??????±???????´?????????????
		int[][] info = new int[n][4];
		//??¶??°?????°?????????
		for(int i = 0; i < n; i++){
			//j???[0]?£? [1]??? [2]??¨?±? [3]?????°
			for(int j = 0; j < 4; j++){

				info[i][j] = scan.nextInt();
			}

		}

		//???????????§??????????¬???????????????????
		int build = 4;
		int flor = 3;
		int room = 10;

		int [][][] ary = new int[build][flor][room];

		//??????????????????????????????????????£??\
		//?£??????°?????????
		for(int intB = 0; intB < build; intB++ ){

			//????????¢?????°?????????
			for(int intF = 0; intF < flor; intF++){

				//??????????????°?????????
				for(int intR = 0; intR < room; intR++){

					//?????????????????£??\
					ary[intB][intF][intR] = 0;
				}
			}
		}


		//?????±????????????????????????????????????
		//??¶??°?????°?????????
		for(int t = 0; t < n; t++){

			int b = info[t][0] - 1;//??????????????????????????????-1
			int f = info[t][1] - 1;
			int r = info[t][2] - 1;
			int p = info[t][3];
			ary[b][f][r] = ary[b][f][r] + p;

			//??\?±???????????????????????????£??????????????¨??????
			if(ary[b][f][r] < 0 ){
				ary[b][f][r] = 0;
			}
			//??\?±???????10??\???????????£?????????9??¨??????
			if(9 < ary[b][f][r] ){
				ary[b][f][r] = 9;
			}


		}




		//??????
		for(int intB = 0; intB < build; intB++ ){

			for(int intF = 0; intF < flor; intF++){

				for(int intR = 0; intR < room; intR++){

					System.out.print(" ");
					System.out.print(ary[intB][intF][intR]);

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

			if(intB != build - 1){
			//?????????#?????????

				//?£???????????????¨??????20?????????
				for(int i =0; i < 20; i++){
					System.out.print("#");
				}
				System.out.println("");
			}

		}

	}
}

Measured memory_bytes: 21272
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    S = [int(input()) for _ in range(N)]

    S.sort()
    result = sum(S)

    if result % 10 == 0:
        for s in S:
            if s % 10:
                print(result - s)
                exit()
    else:
        print(result)
        exit()

    print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<stdio.h>

int main()
{

	int m, f, r;
	char seiseki;

	while (1){

		scanf(" %d %d %d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1)break;
		if (m == -1 || f == -1)
		{
			seiseki = 'F';
		}
		else if (m + f >= 80)
		{
			seiseki = 'A';
		}
		else if (m + f >= 65)
		{
			seiseki = 'B';
		}
		else if (m + f >= 50)
		{
			seiseki = 'C';
		}
		else if (m + f >= 30)
		{
			if (r >= 50)
			{
				seiseki = 'C';
			}
			else
			{
				seiseki = 'D';
			}

		}
		else
		{
			seiseki = 'F';
		}

		printf("%c\n", seiseki);
	}
	return 0;
}

Measured memory_bytes: 596
n=int(input())
a=input()
b=input()
c=input()
a=list(a)
b=list(b)
c=list(c)
ans=0
for aa,bb,cc in zip(a,b,c):
    t=set()
    t.add(aa)
    t.add(bb)
    t.add(cc)
    ans+=len(t)-1
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public enum Type{
		Queen,
		Not,
		Undefined,
	}

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;

	public static final int H = 8;
	public static final int W = 8;
	public static final int num_diff = 8;

	public static final int diff_row[] = {-1,-1,-1,0,0,1,1,1};
	public static final int diff_col[] = {-1,0,1,-1,1,-1,0,1};

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		Type first[][] = new Type[8][8];

		for(int row = 0; row < H; row++){
			for(int col = 0; col < W; col++){
				first[row][col] = Type.Undefined;
			}
		}

		int N = scanner.nextInt();
		int tmp_row,tmp_col;

		for(int loop = 0; loop < N; loop++){

			tmp_row = scanner.nextInt();
			tmp_col = scanner.nextInt();

			paint(first,tmp_row,tmp_col);
		}

		recursive(0,0,first,N);
	}

	//table[row][col]にあるQueenの経路を塗る
	public static void paint(Type table[][],int row,int col){

		table[row][col] = Type.Queen;

		int tmp_row,tmp_col;

		for(int i = 0; i < num_diff; i++){

			tmp_row = row+diff_row[i];
			tmp_col = col+diff_col[i];

			while(rangeCheck(tmp_row,tmp_col)){

				table[tmp_row][tmp_col] = Type.Not;

				tmp_row += diff_row[i];
				tmp_col += diff_col[i];

			}
		}
	}

	//table[row][col]にQueenを置けるか調べる
	public static boolean is_ok(Type table[][],int row,int col){

		//未定義マスでなければfalse
		if(table[row][col] != Type.Undefined)return false;

		int tmp_row,tmp_col;

		//他のQueenと衝突するか調べる
		for(int i = 0; i < num_diff; i++){

			tmp_row = row+diff_row[i];
			tmp_col = col+diff_col[i];

			while(rangeCheck(tmp_row,tmp_col)){

				if(table[tmp_row][tmp_col] == Type.Queen){
					return false;
				}

				tmp_row += diff_row[i];
				tmp_col += diff_col[i];
			}
		}
		return true;
	}

	public static void recursive(int base_row,int base_col,Type table[][],int put_num){

		if(put_num == 8){

			for(int row = 0; row < H; row++){
				for(int col = 0; col < W; col++){

					if(table[row][col] == Type.Queen){

						System.out.print("Q");

					}else{
						System.out.printf(".");
					}
				}
				System.out.print("\n");
			}
			return;
		}

		//置かないで次へ
		if(base_col == 7){
			if(base_row == 7)return;

			recursive(base_row+1,0,table,put_num);

		}else{
			recursive(base_row,base_col+1,table,put_num);
		}

		//置けるなら置く
		if(is_ok(table,base_row,base_col)){

			Type next[][] = new Type[8][8];
			for(int row = 0; row < H; row++){
				for(int col = 0; col < W; col++){
					next[row][col] = table[row][col];
				}
			}
			paint(next,base_row,base_col);

			if(base_col == 7){

				if(base_row == 7){
					return;
				}else{
					recursive(base_row+1,0,next,put_num+1);
				}

			}else{
				recursive(base_row,base_col+1,next,put_num+1);
			}
		}
	}

	public static boolean rangeCheck(int row,int col){

		if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1){
			return true;
		}else{
			return false;
		}
	}
}



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

typedef long long ll;
typedef long double ld;

#define n1		      "\n"
#define B                     begin()
#define E                     end()
#define F                     first
#define S                     second
#define pb                    push_back
#define pf                    push_front
#define popb                  pop_back()
#define popf                  pop_front()

const int BIG=1e5+55;
const int BIGG=1e9+7;
const ll BIGGE=1e12+55;
const double SML=(1e-7);

using namespace std;

    int n,ma = 0;
    string s[2*BIG];
    map <string,int> m;
    pair <int,string> p[2*BIG];
    set <string> ss;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    cout.tie(NULL);
    cin >>n;
    for (int i=0; i<n; i++) {
        cin >>s[i];
        m[s[i]]++;
        ma = max(m[s[i]] , ma);
    }
    for (int i=0; i<n; i++) {
        if (m[s[i]] == ma)
            ss.insert(s[i]);
    }
    for (auto i:ss)
        cout <<i <<n1;



    return 0;
}


Measured memory_bytes: 37888