akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _0048
{
    class Program
    {
        static void Main(string[] args)
        {
            string temp = "";
            string[] weightclass= new string[11] { "light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy" };
            double[] weight = new double[11] { 48.00, 51.00, 54.00, 57.00, 60.00, 64.00, 69.00, 75.00, 81.00, 91.00 ,200.00};

            while ((temp = Console.ReadLine()) !=　null)
            {
                double kg = double.Parse(temp);
                for (int i = 0; i < weight.Length; i++ )
                {
                    if (kg <= weight[i])
                    {
                        Console.WriteLine(weightclass[i]);
                        break;
                    }
                }
            }
        }
    }
}



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

import numpy as np

if __name__ == '__main__':
    N = int(input())
    T, A = map(int, input().split(' '))
    H = [int(h) for h in input().split(' ')]

    t_diff = np.array([abs((T - h * 0.006) - A) for h in H])
    print(t_diff.argmin() + 1)


Measured memory_bytes: 12444
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

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

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int alice = 0, bob = 0;
  rep(i,n) {
    if(i % 2 == 0) alice += a[i];
    if(i % 2 == 1) bob   += a[i];
  }

  cout << alice - bob << endl;
  return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int L, R;
    cin >> L >> R;
    int d;
    cin >> d;
    
    int ans = 0;
    for(int i=L; i<=R; i++)
    {
        if(i%d==0) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
const int MOD=1e9+7;
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

using namespace std;

int n,a[300005];
class DXorSum4 {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n;
		f(i,0,n)
			in >> a[i];
		sort(a,a+n);
		int pow2[65]={0},cnt[65]={0};
		pow2[0]=1;
		f(i,1,62)
			pow2[i]=(pow2[i-1]*2)%MOD;
		f(j,0,62)
			if(a[0]&(1ll<<j))
				cnt[j]++;
		int ans=0;
		f(i,1,n)
		{
			f(j,0,62)
			{
				if(a[i]&(1ll<<j))
					ans+=((i-cnt[j])*pow2[j]);
				else
					ans+=(cnt[j]*pow2[j]);
				if(ans>=MOD)
					ans%=MOD;
			}
			f(j,0,62)
				if(a[i]&(1ll<<j))
					cnt[j]++;
		}
		out << ans << "\n";
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	DXorSum4 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2560
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;




int main(){
    ll q,h,s,d;
    cin>>q>>h>>s>>d;
    h=min(h,q*2);
    s=min(s,h*2);
    d=min(d,s*2);
    ll n;
    cin>>n;
    ll ans=n/2*d;
    ans+=n%2*s;
    cout<<ans<<endl;
    
    return 0;
}


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

#define true 1;
#define false 0;

int main(void){
  int n,cnt;
  char is_prime[1000000];
  
  while(1){

    cnt = 0;

  cin >> n;
  if( n == 0 ) break;

  for( int i = 0 ; i <= 2*n ; i++ ){
    is_prime[i] = true;
  }

  is_prime[0] = is_prime[1] = false; 

  for( int i = 2 ; i*i <= 2*n ; i++ )
    if( is_prime[i] )
      for( int j = i*2 ; j <= 2*n ; j += i )
	is_prime[j] = false;

  for( int i = n + 1 ; i <= 2*n ; i++ ){
    if( is_prime[i] ) cnt++;
}

  cout << cnt << endl;

  }

  return 0;
}

Measured memory_bytes: 1408
h,w,kk=gets.split.map &:to_i
ass=[[0]*(w+1)]
h.times{
  t=0
  as=[0]
  pas=ass[-1]
  ass.push(as)
  gets.chomp.each_char.with_index(1){|c,i|
    as.push(pas[i]+t+=(c==?1 ? 1 : 0))
  }
}
ret=h+w-2
(2**(h-1)).times{|i|
  ds=[0]
  (h-1).times{|j|
    ds.push(j+1) if i[j]==1
  }
  ds.push(h)
  s=ds.size-1
  t=s-1
  wp=0
  1.upto(w){|j|
    1.upto(s){|k|
      break if ass[ds[k]][j]-ass[ds[k-1]][j]-ass[ds[k]][wp]+ass[ds[k-1]][wp]>kk
    } and next
    break if j==wp+1
    t+=1
    break if t>=ret
    wp=j-1
  } or next
  break if ret==0
  ret=t if t<ret
}
puts ret

Measured memory_bytes: 3964
#include<iostream>
#include<cstring>
#include<iomanip>
#define int long long
using namespace std;
double dp[3001][3001];
double func(double a[], int i, int x)
{
	if (x == 0)
	{
		return 1;
	}
	if (i == 0)
	{
		return 0;
	}
	if (dp[i][x] > -0.9)
	{
		return dp[i][x];
	}
	return dp[i][x] = a[i] * func(a, i - 1, x - 1) + (1 - a[i]) * (func(a, i - 1, x));
}
int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int n;
	cin >> n;
	double a[n + 1];
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	memset(dp, -1, sizeof(dp));
	double ans = func(a, n, (n + 1) / 2);
	cout << fixed << setprecision(12) << ans << "\n";
}

Measured memory_bytes: 74320
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int input = Integer.parseInt(scan.next());
        //int second = Integer.parseInt(scan.next());
        //long in = Long.parseLong(scan.next());
        //String s = scan.next();
        //String second = scan.next();
        //for (int i = 1; i <=input; i++) {
        //}
        for(int i=1;i<=9;i++) {
            for(int j=1;j<=9;j++) {
                if(input == (i*j)) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }

    public static void res(boolean flg) {
        if(flg) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23252
import math
import collections


def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if num != 1:
                factor.append(num)
    if not factor:
        return -1
    else:
        factor.append(n)
        return factor


n = int(input())
l = trial_division(n)
if n == 1:
    print(0)
    exit(0)
if l == -1:
    print(1)
    exit(0)
if l[len(l) - 1] == 1:
    l = l[:-1]
c = collections.Counter(l)

ans = 0
for k, v in c.items():
    s = 1
    for i in range(1, v):
        if i * (i + 1) <= v * 2:
            s = max(s, i)
    ans += s
print(ans)


Measured memory_bytes: 9488
import java.io.*;
import java.util.Scanner;

public class Main{
	public static void main(String[] arsg) throws IOException{
		Scanner scan = new Scanner(System.in);
		
		int[] x = new int[6];
		
		for(int i = 0;i<6;i++){
			x[i] = scan.nextInt();
		}
		String str = scan.next();
		
		for(int i = 0;i<str.length();i++){
			char y = str.charAt(i);
			if(String.valueOf(y).equals("S")){
				int a = x[0];
				int b = x[1];
				int c = x[2];
				int d = x[3];
				int e = x[4];
				int f = x[5];
				x[0]=e;
				x[1]=a;
				x[2]=c;
				x[3]=d;
				x[4]=f;
				x[5]=b;		
			}
			else if(String.valueOf(y).equals("E")){
				int a = x[0];
				int b = x[1];
				int c = x[2];
				int d = x[3];
				int e = x[4];
				int f = x[5];
				x[0]=d;
				x[1]=b;
				x[2]=a;
				x[3]=f;
				x[4]=e;
				x[5]=c;
			}
			else if(String.valueOf(y).equals("N")){
				int a = x[0];
				int b = x[1];
				int c = x[2];
				int d = x[3];
				int e = x[4];
				int f = x[5];
				x[0]=b;
				x[1]=f;
				x[2]=c;
				x[3]=d;
				x[4]=a;
				x[5]=e;
			}
			else if(String.valueOf(y).equals("W")){
				int a = x[0];
				int b = x[1];
				int c = x[2];
				int d = x[3];
				int e = x[4];
				int f = x[5];
				x[0]=c;
				x[1]=b;
				x[2]=f;
				x[3]=a;
				x[4]=e;
				x[5]=d;
			}
		}
		
		System.out.println(x[0]);
	}
}							

Measured memory_bytes: 26332
N = int(input())
S = input()
pos = 0
minpos = 0
mini = 0
for i in range(N):
    if S[i]=="W":
        pos += 1
    else:
        pos -= 1
    if pos < minpos:
        minpos = pos
        mini = i

s1 = S[0:mini].count("W")
s2 = S[mini+1:N].count("E")
print(s1+s2)

Measured memory_bytes: 3700
#include <cstdio>
int main(){
  int i, H, W;
  for (; ;) {
    scanf("%d %d", &H, &W);
    if (H==0 && W==0) break;
    char s1[W+1];
    char s2[W+1];
    for (i=0; i<W; i++) {
      s1[i]='#';
    }
    s1[i]='\0';
    s2[0]='#';
    for (i=1; i<W-1; i++) {
      s2[i]='.';
    }
    s2[i]='#';
    s2[i+1]='\0';
    printf("%s\n", s1);
    for (i=0; i<H-2; i++) {
      printf("%s\n", s2);
    }
    printf("%s\n\n", s1);
  }
}


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

// 入力
int H, W;
vector<vector<int>> field;

// 探索
void dfs(int h, int w) {
    field[h][w] = 0;

    // 八方向を探索
    for (int dh = -1; dh <= 1; ++dh) {
        for (int dw = -1; dw <= 1; ++dw) {
            int nh = h + dh, nw = w + dw;

            // 場外アウトしたり、0 だったりはスルー
            if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if (field[nh][nw] == 0) continue;

            // 再帰的に探索
            dfs(nh, nw);
        }
    }
}

int main() {
    // 入力受け取り
    while (cin >> W >> H) {
        if (H == 0 || W == 0) break;
        field.assign(H, vector<int>(W, 0));
        for (int h = 0; h < H; ++h) for (int w = 0; w < W; ++w) cin >> field[h][w];

        // 探索開始
        int count = 0;
        for (int h = 0; h < H; ++h) {
            for (int w = 0; w < W; ++w) {
                if (field[h][w] == 0) continue; // 残島じゃなかったらスルー
                dfs(h, w);
                ++count;
            }
        }
        cout << count << endl;
    }
}


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

struct F {
	long long a, b;
	F() {}
	F(long long _a, long long _b) : a(_a), b(_b) {}
	F operator + (const F &f) {
		long long x = a * f.a, y = b * f.a + a * f.b;
		long long g = __gcd(x, y);
		return F(x / g, y / g);
	}
	F operator - (const F &f) {
		long long x = a * f.a, y = b * f.a - a * f.b;
		long long g = __gcd(x, y);
		return F(x / g, y / g);
	}
	F operator * (const F &f) {
		long long x = a * f.a, y = b * f.b;
		long long g = __gcd(x, y);
		return F(x / g, y / g);
	}
	F operator / (const F &f) {
		long long x = a * f.b, y = b * f.a;
		long long g = __gcd(x, y);
		return F(x / g, y / g);
	}
};
const double pi = acos(-1);
const double eps = 1e-8;
inline int sign(double a) {
	return a < -eps ? -1 : a > eps;
}
inline int cmp(double a, double b) {
	return sign(a - b);
}
double add(double a, double b) {
	if (abs(a + b) < eps * (abs(a) + abs(b))) return 0;
	return a + b;
}
struct P {
	double x, y;
	P() {}
	P(double x, double y) : x(x), y(y) {}
	P operator + (const P &p) { return P(add(x, p.x), add(y, p.y)); }
	P operator - (const P &p) { return P(add(x, -p.x), add(y, -p.y)); }
	P operator * (double d) { return P(x * d, y * d); }
	P operator / (double d) { return P(x / d, y / d); }
	double dot(const P &p) { return add(x * p.x, y * p.y); }
	double det(const P &p) { return add(x * p.y, -y * p.x); }
	double alpha() { return atan2(y, x); }
	double abs() { return sqrt(abs2()); }
	double abs2() { return x * x + y * y; }
	P rot90() { P(-y, x); }
	P unit() { return *this / abs(); }
	bool operator < (P p) const {
		int c = cmp(x, p.x);
		if (c) return c == -1;
		return cmp(y, p.y) == -1;
	}
	friend istream& operator>>(istream &in, P &p) {
		in >> p.x >> p.y;
		return in;
	}
	friend ostream& operator<<(ostream& out, P &p) {
		out << p.x << ' ' << p.y;
		return out;
	}
};
P projection(P p1, P p2, P q) {
	P dir = p2 - p1;
	return p1 + dir * (dir.dot(q - p1) / dir.abs2());
}
P reflection(P p1, P p2, P q) {
	return projection(p1, p2, q) * 2 - q;
}
double dist(const P &a, const P &b) {
	double x = a.x - b.x, y = a.y - b.y;
	return sqrt(x * x + y * y);
}
bool on_seg(P p1, P p2, P q) {
	return (p1 - q).det(p2 - q) == 0 && (p1 - q).dot(p2 - q) <= 0;
}
P intersection(P p1, P p2, P q1, P q2) {
	return p1 + (p2 - p1) * ((q2 - q1).det(q1 - p1) / (q2 - q1).det(p2 - p1));
}

int main() {
#ifdef LOCAL_DEFINE
	//freopen("data.in", "rt", stdin);
	//freopen("data.out", "w", stdout);
	auto _start = chrono::high_resolution_clock::now();
#endif

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	P p1, p2;
	cin >> p1 >> p2;
	int q;
	cin >> q;
	while (q--) {
		P p;
		cin >> p;
		P ans = reflection(p1, p2, p);
		cout << ans << '\n';
	}

#ifdef LOCAL_DEFINE
	auto _end = chrono::high_resolution_clock::now();
	cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}


Measured memory_bytes: 3300
#pragma GCC optimize ("O3,unroll-loops")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define spIO ios::sync_with_stdio(false);cin.tie(0)
string s, t, u;
int a, b;
int main()
{
	spIO;
	cin >> s >> t >> a >> b >> u;
	if (u == s)
		cout << a - 1 << ' ' << b;
	else
		cout << a << ' ' << b - 1;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
int m, f, r;

do{
std::cin >> m >> f >> r;
int sum = m + f;

if(m == -1 || f == -1){
if(m == -1 && f == -1 && r == -1){
}
else{
std::cout << 'F' << std::endl;
}
}
else if(sum >= 80){
std::cout << 'A' << std::endl;
}
else if(sum >= 65 && sum < 80){
std::cout << 'B' << std::endl;
}
else if(sum >= 50 && sum < 65){
std::cout << 'C' << std::endl;
}
else if(sum >= 30 && sum < 50){
if(r >= 50){
std::cout << 'C' << std::endl;
}
else {
std::cout << 'D' << std::endl;
}
}
else if(sum < 30){
std::cout << 'F' << std::endl;
}
} while(!(m == -1 && f == -1 && r == -1));
}

Measured memory_bytes: 3100
require 'pp'

n = gets.to_i
s = gets.chomp!.chars

x = s.tally

r = x['R'] || 0
g = x['G'] || 0
b = x['B'] || 0
ans = r * g * b

m_sum = 0
1.upto(n) do |i|
    j = 0
    while j + 2 * i < n
        if s[j] != s[j+i] && s[j] != s[j+2*i] && s[j+i] != s[j+2*i] 
            m_sum += 1
        end
        j += 1
    end
end 

puts ans - m_sum


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

#define Ni 3

int pzl[Ni][Ni],tmp[Ni][Ni];
int Dx[4]={0,1,0,-1},Dy[4]={1,0,-1,0};

void emblem(int *a,int *b){
  int i,j;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if(!pzl[i][j]){
	*a = j;
	*b=i;
      }
    }
  }
}

void swap(int *a,int *b){
  int tmp;
  tmp =*a;
  *a = *b;
  *b = tmp;
}

int check(){
  int i,A,S=0;
  for(i=0;i<9;i++){
    A = pzl[i/3][i%3];
    if(A){
      A--;
      S += abs(i/3-A/3) + abs(i%3 - A%3);
    }
  }
  
  return S;
}

int defain(int a,int b,int P,int D,const int shin){
  int i,hi,A,B,result;
  hi = check();
  if(hi==0){
    return D;
  }
  
  if(D+hi>shin){
    return -1;
  }

  for(i=0;i<4;i++){
    A = a+Dx[i];
    B = b+Dy[i];
    if(~P && i==(P+2)%4) {
      continue;
    }
    if(!(0<=A && A<3 && 0<=B && B<3)){
      continue;
    }
    swap(&pzl[b][a],&pzl[B][A]);
    result = defain(A,B,i,D+1,shin);
    if(~result){
      return result;
    }
    swap(&pzl[b][a],&pzl[B][A]);
  }
  
  return -1;
  
}

int main(){
  int i,j,li,TA,a,b;

  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&pzl[i][j]);
    }
  }

  emblem(&a,&b);
  for(li=0;li<100;li++){
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
	tmp[i][j]=pzl[i][j];
      }
    }
    
    TA = defain(a,b,-1,0,li);
    if(TA!=-1){
      printf("%d\n",TA);
      break;
    }

    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
	pzl[i][j]=tmp[i][j];
      }
    }

    TA = -1;
    if(li==99){
      printf("%d\n",TA);
    }
  }

  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define pb push_back
#define Nmax 210
#define M 63
using namespace std;
typedef long long ll;
string s;
int N, n, T;
bitset<M> A[Nmax];
ll a[Nmax];

bool gauss() { //true if linearly dep
  int i=0,j=0;
  
  while(i<N && j<M) {
    int k;
    for(k=i;k<N;++k) if(A[k][j]) break;
    if(k==N) { ++j; continue; }
    if(k!=i) swap(A[i], A[k]);

    for(int u=i+1;u<N;++u) {
      for(int q=j+1;q<M;++q) A[u][q] = (A[u][q] ^ (A[u][j]*A[i][q]));
      A[u][j]=0;
    }
    ++i; ++j;
  }

  return (A[N-1] == 0);
}

int main() {

  cin>>T;
  while(T--) {
    cin>>n;
    N = 0;
    for(int i=0;i<n;++i) cin>>a[i];

    cin>>s;
    if(s[N-1] == '1') {
      cout<<"1\n";  
      continue;
    }
    bool ok = true;

    for(int i=n-1;i>=0;--i) {
      A[N++] = a[i];
      if(s[i] == '1') {
        if(!gauss()) {
          ok = false;
          break;  
        }
        --N;
      } else {
        if(gauss()) {
          --N;
        }
      }
    }
    
    if(!ok) {
      cout<<"1\n";  
    } else {
      cout<<"0\n";
    }
  }
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}


long long gcd(long long x, long long y) {
	long long r;
	if(x < y) swap(x, y);

	while(y > 0){
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

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

	vector<long long> ans;
	if(n % 2){
		ans = vector<long long>({2, 3, 25});
	}else{
		ans = vector<long long>({2, 3, 25, 15000});
	}

	vector<bool> used(30000, 0);
	for(auto i : ans) used[i] = true;
	for (int i = 4; i < 15000; i+=2) {
		if(ans.size() == n) break;
		if(used[i]) continue;
		ans.emplace_back(i);
		ans.emplace_back(30000 - i);
		used[i] = used[30000 - i] = true;
	}
	for (int i = 3; i < 15000; i+=3) {
		if(ans.size() == n) break;
		if(used[i]) continue;
		ans.emplace_back(i);
		ans.emplace_back(30000 - i);
		used[i] = used[30000 - i] = true;
	}
	for (int i = 5; i < 15000; i+=5) {
		if(ans.size() == n) break;
		if(used[i]) continue;
		ans.emplace_back(i);
		ans.emplace_back(30000 - i);
		used[i] = used[30000 - i] = true;
	}


	assert(n == ans.size());

	rep(i,n){
		assert(ans[i] <= 30000);
		assert(ans[i] >= 1);
	}

	set<long long> s(all(ans));
	assert(s.size() == n);

	long long sum = accumulate(all(ans),0LL);
	rep(i,n){
		assert(gcd(sum - ans[i], ans[i]) != 1); 
	}

	long long cur = gcd(ans[0], ans[1]);
	rep(i,n){
		cur = gcd(cur, ans[i]);
	}
	assert(cur == 1);

	for(auto i : ans){ cout << i << endl; }
}


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

using namespace std;
inline int read() {
    int x = 0;
    bool f = 1;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
    for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
    if (f) return x;
    return 0 - x;
}
typedef long long ll;
const int maxn = 200010;
const int inf = 0x3f3f3f3f;
const ll mod = 1000000000 + 7;
struct node {
    ll x, h;
} p[maxn];
bool cmp(node a, node b) {
    return a.x < b.x;
}
ll n, d, a, c[maxn];
int main() {
    cin >> n >> d >> a;
    for (int i = 1; i <= n; i++) {
        cin >> p[i].x >> p[i].h;
    }
    sort(p + 1, p + n + 1, cmp);
    ll ans = 0;
    for (int i = 1, j = 1; i <= n; i++) {
        while (j <= n && p[j].x <= p[i].x + 2ll * d) j++;

        ll tmp = max((p[i].h - c[i] * a + a - 1) / a, 0ll);

        ans += tmp;
        c[i] += tmp;
        c[j] -= tmp;
        c[i + 1] += c[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
int main(void){
  int a = 0, b = 0, c = 0;
  int sum;
  scanf("%d %d %d",&a, &b, &c);
  sum = 100*a + 10*b + c;
  if(sum % 4 == 0){
    puts("YES\n");
  }else{
    puts("NO\n");
  }
  return 0;
}
 

Measured memory_bytes: 128
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
vector<pair<ll,ll>> v;

int main()
{
	ll n,k;
	cin>>n>>k;

	if(k>(((n-1)*(n-2))/2)){
	cout<<"-1"<<endl;
	return 0;
	}

	forn(i,n-1){
		v.pb(mp((ll)1,i+2));
	}
	k=(((n-1)*(n-2))/2)-k;

	ll i=2;
	while(k>0){
		ll j=i+1;
		while((k>0)&&(j<=n)){
			v.pb(mp(i,j));
			j++;
			k--;
		}
		i++;
	}

	cout<<v.size()<<"\n";
	for(auto x:v){
		cout<<x.fi<<" "<<x.se<<endl;
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

vector<int> adj[100005];

int dp[100005];

int solve(int cur){
	if(dp[cur] != -1)
		return dp[cur];
	dp[cur] = 0;
	
	for(auto x : adj[cur]){
		solve(x);
		dp[cur] = max(dp[cur],dp[x] + 1);
	}
	return dp[cur];
}

int32_t main(){
	int n, m;
	cin >> n >> m;
	
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
	}
	
	memset(dp,-1,sizeof dp);
	
	int ans = 0;
	
	for(int i = 1; i <= n; i++){
		ans = max(ans,solve(i));
	}
	
	cout << ans << endl;

	return 0;
}



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

int main() {
  int a,b;
  cin >> a >> b;
  if ((a*b)%2 == 1) {
    cout << "Odd";
  }
  else if ((a*b)%2 == 0) {
    cout << "Even";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main (){
  string s ,t;
  cin >>s >>t;
  int x = stoi (s+ t );
  for ( int i =1; i <=1000; i ++){
    if ( i*i == x ){
      puts ("Yes");
      return 0;
    }
  }
  puts ("No");
}

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

using namespace std;




int main() {
    string s , t;
    cin >> s >> t;
    int m = s.length(), n = t.length();

    vector<vector<int>> v(m + 1, vector<int> (n + 1));
    for(int i = 0; i <= m; i++ ){
        for(int j =0 ; j <= n ; j++){
            if(i == 0 || j == 0) v[i][j] = 0;
            else if (s[i-1] == t[j-1]){
                v[i][j] = 1 + v[i-1][j-1];
            }
            else{
                v[i][j] = max(v[i-1][j], v[i][j-1]);
            }
        }
    }

    int index = v[m][n];
    vector<char> ans(index + 1 , '\0');
    int i = m , j = n;
    while(i > 0 && j > 0 ){
        if(s[i-1] == t[j-1]){
            
            ans[index-1] = s[i-1];
            i--;
            j--;
            index--;
        }
        else if(v[i-1][j] > v[i][j-1]) i--;
        else j--;
    }

    

    
    for(int p = 0; p < v[m][n]; p++) cout<<ans[p];

    return 0;
}


Measured memory_bytes: 38556
N = int(input())
tree = [None] * N
root = set(range(N))
for _ in [0] * N:
    i, l, r = list(map(int, input().split()))
    tree[i] = [l,r] + [None] * 5  # parent(2), sibling(3), degree(4), depth(5), height(6)
    root -= {l, r}

def set_pd(i, parent, sibling, depth):
    if i == -1:return -1
    node = tree[i]
    l, r = node[0], node[1]
    node[2], node[3], node[5] = parent, sibling, depth
    node[4] = (l != -1) + (r != -1)
    height = node[6] = max(set_pd(l, i, r, depth + 1), set_pd(r, i, l, depth + 1)) + 1
    return height

set_pd(root.pop(), -1, -1, 0)

for i, node in enumerate(tree):
    print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(
        i, *node[2:], 'root' if not node[5] else 'internal node' if node[4] else 'leaf'))


Measured memory_bytes: 5612
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 20:41:42 2020

@author: liang
"""
#E
N = int(input())
d = list()
for i in range(N):
    x, y = map(int,input().split())
    d.append((x,y))

d.sort(key=lambda x:x[0]+x[1])
#print(d)

ans1 = abs(d[0][0] - d[N-1][0]) + abs(d[0][1] - d[N-1][1])

d.sort(key=lambda x:x[0]-x[1])

ans2 = abs(d[0][0] - d[N-1][0]) + abs(d[0][1] - d[N-1][1])

ans = max(ans1, ans2)

print(ans)

Measured memory_bytes: 45732
N = int(input())

lst = []
for i in range(N):
  N, K = map(int, input().split())
  lst.append((K-N, N, K))

lst.sort(key=lambda tup: tup[2])
count = 0
for ind, x in enumerate(lst):
  if count > x[0]:
    print("No")
    exit()
  count += x[1]

print("Yes")


Measured memory_bytes: 39756
A,B,C,D = map(int,input().split())

flag = 0
while(A>0 and C>0):
    if(flag == 0):
        C = C - B
        flag = 1
    else:
        A = A - D
        flag = 0

if(flag==0):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9076
#include<bits/stdc++.h>
using namespace std;
 
 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);

    long long n,m;
    cin>>n>>m;
    long long a[n];
    long long b,c;

    pair<long long,long long> p[m];

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

    for(int i=0;i<m;i++){
        cin>>b>>c;
        p[i]=make_pair(c,b);
    }

    sort(p,p+m);
    reverse(p,p+m);

    long long ans[n]={};
    
    sort(a,a+n);

    long long cnt=0;
    for(int i=0;i<m;i++){
        int c=0;
        while(c<p[i].second && cnt<n){
            ans[cnt]=p[i].first;
            c++;
            cnt++;
        }
    }

    int now=n-1;
    for(int i=n-1;i>=0;i--){
        if(ans[i]<a[now]){
            now--;
            ans[i]=a[now+1];
        }
    }
    long long sum=0;
    for(int i=0;i<n;i++){
        sum+=ans[i];
    }
    cout<<sum<<endl;


}

Measured memory_bytes: 3328
/**
 *Code Author: codeknight13
 *Institution: IIT(ISM)
**/

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

/*
use these format of input when number of inputs not provided
while(scanf("%lld",&n)!=EOF)
*/

#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define vi vector< ll >
#define vii vector< vi >
#define viii vector< vii >
#define pii pair< ll , ll >
#define vpii vector< pii >
#define mii unordered_map< ll , ll >
#define mci map< char , ll >
#define pq priority_queue
#define str string
#define len length()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl cout <<  endl
#define sp " "
#define all(ar) ar.begin(), ar.end()
#define itern(n) for (int i=0; i<n; i++)
#define ritern(n) for (int i=n-1; i>=0; i--)
#define sz(x) ((int)(x).size())
#define pi acos(1);                   /* pi */
#define inf (int(1e9+7))
#define fl(x) int(x)
#define mod %(inf)
#define yes "YES"
#define no "NO"
#define null NULL
//debugger
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
//functions
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}


//#------------------------------complete template------------------------------#//



int main()
{
	fast;
	vector<vector<int > > a(int(1e3+1e2),vector<int> (int(1e3+1e2),-2));
	int n,m;
	cin >> n >> m;
	queue<pii> q;
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=m; j++)
		{
			char x;
			cin >> x;
			if (x=='#') a[i][j]=0;else a[i][j]=-1;
			if (a[i][j]==0) q.push({i,j});
		}
	}
	while(!q.empty())
	{
		pii p=q.front();
		q.pop();
		int i=p.ff,j=p.ss;
		if (a[i+1][j]==-1){a[i+1][j]=a[i][j]+1;q.push({i+1,j});}
		if (a[i][j+1]==-1){a[i][j+1]=a[i][j]+1;q.push({i,j+1});}
		if (a[i-1][j]==-1){a[i-1][j]=a[i][j]+1;q.push({i-1,j});}
		if (a[i][j-1]==-1){a[i][j-1]=a[i][j]+1;q.push({i,j-1});}
	}
	int ans=0;
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=m; j++)
		{
			ans=max(a[i][j],ans);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 21428
#include <iostream>
#include <vector>
#include <queue>
#include <string>

using namespace std;
typedef long long ll;

void vecprint(vector<ll> v) {
    for(auto x : v) {
        cout << x << " ";
    }
    cout << endl;
}

void qprint(priority_queue<ll> q) {
    while(!q.empty()) {
        cout << q.top() << " ";
        q.pop();
    }
    cout << endl;
}

int main(void) {
    int n;
    cin >> n;
    
    cout << n*n*n << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		long x = Long.parseLong(sc.next());
		long result;
		if(((b - a + 1)%x == 0) || (0 < a%x && a%x <= b%x))
			result = (b - a + 1)/x;
		else
			result = (b - a + 1)/x + 1;
		System.out.println(String.valueOf(result));
	}
}

Measured memory_bytes: 9684
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
from statistics import median_low,median_high
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrX = list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)

X = sorted(arrX)
low = median_low(X)
high = median_high(X)

for i in arrX:
    if i <= low:
        print(high)
    elif i >= high:
        print(low)

# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 27192
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    int a[1000];
    int ans=0;
    int sum=0;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       cin>>a[i];
   }
   int r=n;
   int l=1;
   sum+=a[l];
    ans+=a[r];
   while(r!=l)
   {
       if(sum>ans)
       {
           r--;
           if((r!=l))
           ans+=a[r];
       }
       else
       {
           l++;
           if(r!=l)
           sum+=a[l];
       }



   }
   cout<<fabs(sum-ans)<<endl;
}


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

int gcc(int x, int y){
  while( x % y > 0){
    int tmp = x % y;
    x = y;
    y = tmp;
  }
  return y;
}

int main(){
  int n;
  cin >> n;
  cout << 2 * n / gcc(2,n) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	static int n, A[];

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

		n = sc.nextInt();
		A = new int[n];
		for (int i = 0; i < n; i++)
			A[i] = sc.nextInt();

		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int M = sc.nextInt();
			System.out.println(IntStream.range(0, n).anyMatch(t -> solve(t, M)) ? "yes" : "no");
		}

		sc.close();
	}

	static boolean solve(int p, int M) {
		if (M == 0)
			return true;
		if (p == n)
			return false;
		return solve(p + 1, M - A[p]) || solve(p + 1, M);
	}
}


Measured memory_bytes: 32612
#理解のためにワーシャルフロイドで解いてみる

h,w=map(int,input().split())
li=[list(map(int,input().split())) for i in range(10)]
a=[list(map(int,input().split())) for i in range(h)]

#参考ページ：https://dai1741.github.io/maximum-algo-2012/docs/shortest-path/

for k in range(10):
    for i in range(10):
        for j in range(10):
            li[i][j] = min(li[i][j], li[i][k] + li[k][j])

ans=0

for i in a:
  for j in i:
    if j!=-1:
      ans+=li[j][1]

print(ans)

Measured memory_bytes: 3316
def power(x, n, d):
    rem = 1
    if n > 0:
        rem = power(x, n // 2, d)
        if n % 2 == 0:
            rem = rem ** 2 % d
        else:
            rem = ((rem ** 2 % d) * x) % d
    return rem

def solve():
    m, n = map(int, input().split())
    print(power(m, n, 1000000007))

solve()

Measured memory_bytes: 7712
<?php


while(true) {
    fscanf(STDIN, "%d", $s);
    if(feof(STDIN))
        break;
    $h = $s / 3600;
    $m = ($s % 3600) / 60;
    $s = ($s % 3600) % 60;
    printf("%d:%d:%d", $h, $m, $s);
    echo PHP_EOL;
}

Measured memory_bytes: 15256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;

int main(){

    string s, t;
    cin >> s >> t;


    if(s.size()!=t.size()-1){
            cout << "No" << endl;
            return 0;
    }
    for (int i = 0; i != s.size();++i){
        if(s[i]!=t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
        cout << "Yes" << endl;
        return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cout<<elem;}cerr<<endl;}

const int mod=998244353;

/*二項係数(mod付き)*/
struct Combination{
	const int max=51e4;			//適宜変更する.
	//const int mod=1e9+7;
	vector<llong> fact,inv,finv;//階乗,逆元,逆元の階乗.
	
	Combination():fact(max),inv(max),finv(max){
		fact[0]=fact[1]=1;
		inv[1]=1;
		finv[0]=finv[1]=1;
		for(int i=2;i<max;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){
		if(n<k) return 0;
		if(n<0 or k<0) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	int big_nCk(int n,int k){//nが大きい場合に使用.
		llong res=1LL;
		REP(i,k) res=res*(n-i)%mod;
		res=res*finv[k]%mod;
		return res;
	}
};

int main(){
	Combination ob;
	
	int n,m,k;
	cin>>n>>m>>k;
	
	vector<llong> mem(n+1);
	mem[1]=m;
	for(int i=2;i<=n;++i){
		mem[i]=mem[i-1]*(m-1)%mod;
	}
	
	llong ans=0;
	for(int i=0;i<=k;++i){
		debug(ob.nCk(n-1,i));
		ans=(ans+mem[n-i]*ob.nCk(n-1,i)%mod)%mod;
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 19008
use std::cmp;

fn main(){
  let nts: Vec<usize> = read_vec();
  let n = nts[0];
  let t = nts[1];
  let s = nts[2];
  
  let mut dp: Vec<usize> = vec![0; t + 1];

  for _ in 0 .. n {
    let ab: Vec<usize> = read_vec();
    let a = ab[0];
    let b = ab[1];
    
    for ts in (0 .. t).rev() {
      let te = ts + b;
      
      if te <= t && (ts <= s && te <= s || ts >= s && te >= s) {
        let m = dp[ts] + a;
        dp[te] = cmp::max(dp[te], m);
      }
    }
  }
  
  let &ans = dp.iter().max().unwrap();
  
  println!("{}", ans);
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 5052
import java.util.HashMap;
import java.util.Scanner;
import java.awt.Point;
public class Main{

   public static void main(String[] args){
      new Main().solve();  
   }

   public void solve(){
      Scanner scanner = new Scanner(System.in);
      long H = scanner.nextLong();
      long W = scanner.nextLong();
      int N = scanner.nextInt();

      Point[] point = new Point[N];
      for(int i=0; i<N; i++){
         int row = scanner.nextInt();
         int col = scanner.nextInt();
         point[i] = new Point(col, row);
      }

      HashMap<Point,Integer> hashmap = new HashMap<Point,Integer>();

      for(int i=0; i<N; i++){
         for(int y=-1; y<2; y++){
            for(int x=-1; x<2; x++){
               Point p = new Point(point[i].x+x, point[i].y+y);
               if(hashmap.get(p) == null){
                  hashmap.put(p,1);
               }else{
                  hashmap.put(p,hashmap.get(p)+1);
               }
            }
         }
      }

      long[] counter = new long[10];
      for(int i=0; i<counter.length; i++){
         counter[i] = 0;
      }
      long sum = (H-2)*(W-2);
      for(HashMap.Entry<Point,Integer> map : hashmap.entrySet()){
         if(1<map.getKey().x && map.getKey().x<W && 1<map.getKey().y && map.getKey().y<H){
            counter[map.getValue()]++;
            sum--;
         }
      }
      counter[0] = sum;
      for(int i=0; i<counter.length; i++){
         System.out.println(counter[i]);
      }

   }

}


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


int main() {
    int A, B;
    cin >> A >> B;
    int v = max(A, B);
    int w = min(A, B);
    long int ans = v;
    while ((ans % w != 0) || !(ans / v > 0)) {
        ans += v;
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	vector<vector<int>> a(3, vector < int>(3));
	rep(i, 3) {
		rep(j, 3) cin >> a[i][j];
	}
	int n;
	cin >> n;
	vector<int> b(n);
	rep(i, n) {
		cin >> b[i]; 
		rep(j, 3) { rep(k, 3){
			if (b[i] == a[j][k]) a[j][k] =200;
		}
		}
	}
		if (a[0][0] + a[1][1] + a[2][2] == 600) {
			cout << "Yes"; return 0;
		}
		if (a[0][0] + a[0][1] + a[0][2] == 600) {
			cout << "Yes"; return 0;
		}
		if (a[0][0] + a[1][0] + a[2][0] == 600) {
			cout << "Yes"; return 0;
		}
		if (a[1][0] + a[1][1] + a[1][2] == 600) {
			cout << "Yes"; return 0;
		}
		if (a[0][1] + a[1][1] + a[2][1] == 600) {
			cout << "Yes"; return 0;
		}
		if (a[0][2] + a[1][2] + a[2][2] == 600) {
			cout << "Yes"; return 0;
		}
		if (a[2][0] + a[2][1] + a[2][2] == 600) {
			cout << "Yes"; return 0;
		}
		if (a[0][2] + a[1][1] + a[2][0] == 600) {
			cout << "Yes"; return 0;
		}
		cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define ll long long  
long double esp=0.00000001;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	long double a,b,c;
	cin>>a>>b>>c;
	if(a+b+2*sqrtl(a*b)<c)cout<<"Yes";
	else cout<<"No";
} 


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

struct Node {int key; Node *l, *r, *p;};
Node *root, *NIL;

void inorder(Node *u)
{
  if(u == NIL) return ;
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}

void preorder(Node *u)
{
  if(u == NIL) return ;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}

void insertkey(int k)
{
  Node *x, *y, *z;
  x = root;
  y = NIL;
  z = (Node*)malloc(sizeof(Node));
  z->key = k;
  z->l = z->r = NIL;
  while(x != NIL)
  {
    y = x;
    if(z->key < x->key)
      x = x->l;
    else x = x->r;
  }
  z->p = y;
  if(y == NIL)
    root = z;
  else
  {
    if(z->key < y->key)
      y->l = z;
    else y->r = z;
  }
}

void output()
{
  inorder(root);  printf("\n");
  preorder(root); printf("\n");
}

Node* findkey(int k)
{
  Node *x = root;
  while(x != NIL && x->key != k)
  {
    if(k < x->key)
      x = x->l;
    else x = x->r;
  }
  return x;
}

int main()
{
  int m, k;
  Node *x = NIL;
  scanf("%d", &m);
  string s;
  for(int i=0; i<m; i++)
  {
    cin >> s;
    if(s == "insert")
    {
      scanf("%d", &k); insertkey(k);
    }
    else if(s == "find")
    {
      scanf("%d", &k);
      x = findkey(k);
      if(x == NIL) printf("no\n");
      else printf("yes\n");
    }
    else output();
  }

  return 0;
}



Measured memory_bytes: 21960
from itertools import product


def makelist(BIT):
    LIST, tmp = [], s[0]
    for si, bi in zip(s[1:], BIT):
        if bi == 1:
            LIST.append(tmp)
            tmp = si[:]
        elif bi == 0:
            tmp = [t + sij for t, sij in zip(tmp, si)]
    else:
        LIST.append(tmp)
    return LIST


def solve(LIST):
    COST, cnt = 0, [li[0] for li in LIST]
    if any(num > k for num in cnt):
        return h * w
    for j in range(1, w):
        tmp = [t + li[j] for t, li in zip(cnt, LIST)]
        if any(num > k for num in tmp):
            COST += 1
            cnt = [li[j] for li in LIST]
        else:
            cnt = tmp[:]
    return COST


h, w, k = map(int, input().split())
s = [[int(sij) for sij in input()] for _ in range(h)]

ans = h * w
for bit in product([0, 1], repeat=(h - 1)):
    numlist = makelist(bit)
    ans = min(ans, solve(numlist) + sum(bit))
print(ans)


Measured memory_bytes: 9492
#include <stdio.h>

int main(){
  int n,d;
  int x[11][11];
  int bucket[50000];
  scanf("%d%d",&n,&d);
  int i,j,k;
  int r,ans=0;
  
  for(i=0;i<50000;i++)bucket[i]=0;
  
  //各座標を代入
  for(i=1;i<=n;i++)for(j=1;j<=d;j++){
    scanf("%d",&x[i][j]);
  }
  
  for(i=1;i<=n;i++)for(j=i+1;j<=n;j++){
    r=0;
    for(k=1;k<=d;k++){
      r+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
    }
    bucket[r]++;
  }
  
  for(i=1;i<200;i++){
    ans += bucket[i*i];
  }
  
  printf("%d\n",ans);
  
  return 0;
}

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

using namespace std;

#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
  	int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int t;cin>>t;
  	cout <<arr[t-1]<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define S(s) (int)((s).size())
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,(v))
#define MA(a,v) a = max(a,(v))
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
int N=100;

int n;
V<int> a;

bool finished() {
    F(i,n) if (a[i] >= n)
        return false;
    return true;
}

int cnt=0;

void lastSteps() {
    //P("hey");
    while (true) {
        int mai = max_element(ALL(a)) - a.begin();
        //P(mai);
        if (a[mai] < n) break;
        cnt++;
        F(i,n) {
            if (i == mai) a[i] -= n;
            else a[i]++;
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    F(i,n) {
        int e; cin>>e;
        a.pb(e);
    }
    while (true) {
        int ma = *max_element(ALL(a));
        if (ma < 2*n) {
            lastSteps();
            break;
        }
        V<int> group;
        int masmall=0;
        F(i,n) {
            if (a[i] >= ma-n)
                group.pb(i);
            else
                MA(masmall, a[i]);
        }
        int steps = (ma-masmall)/(n+1);
        F(i,n) {
            if (a[i] >= ma-n)
                a[i] -= (n-S(group)+1)*steps;
            else
                a[i] += S(group)*steps;
        }
        cnt += S(group)*steps;
    }
    printf("%lld\n", cnt);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int i, j, n, A, B, cal, nedan,max = 0,temp,C;
	int c[100];
	cin >> n >> A >> B >> cal;
	for (i = 0; i < n; i++){
		cin >> c[i];
	}
	for (i = 0; i < n; i++){
		for (j = i + 1; j < n; j++){
			if (c[i] < c[j]){
				temp = c[i];
				c[i] = c[j];
				c[j] = temp;
			}
		}
	}
	C = cal;
	for (i = 0; i < n; i++){
		for (j = 0; j < i; j++){
			C += c[j];
		}
		nedan = B*j + A;
		C = C / nedan;
		//cout << C << endl;
		if (C > max){
			max = C;
		}
		C = cal;
	}
	cout << max << endl;
	return 0;
}

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

multiset<int> se;

int main()
{
    // freopen("powers.in", "r", stdin);
    // freopen("powers.out", "w", stdout);
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        int x;
        scanf("%d", &x);
        se.insert(x);
    }
    int answer = 0;
    while (!se.empty())
    {
        multiset<int>::iterator it = se.end();
        it--;
        int back = *it;
        se.erase(it);
        int i = 1;
        for (; i <= back; i <<= 1)
            ;
        if (se.find(i - back) != se.end())
        {
            se.erase(se.find(i - back));
            answer++;
        }
    }
    printf("%d\n", answer);
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    string s;
    in>>s;
    int n=s.length();
    int ans=0;
    fr(i,n) if(s[i]!=s[n-1-i]) ++ans;
    ans/=2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256