akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

const int N = 1e5+1;
int n, m;
vector <int> a[N];

int main()
{
  fastio;
  cin >> n >> m;
  for (int i = 1; i <= m; i++){
    int u, v; cin >> u >> v;
    a[u].push_back(v); a[v].push_back(u);
  }
  queue <int> Q; 
  vector <int> mark(n + 1, 0);
  mark[1] = 1; Q.push(1);
  while (Q.size()){
    int u = Q.front();
    Q.pop();
    for (int v : a[u]){
      if (mark[v]) continue;
      mark[v] = u; Q.push(v);
    }
  }
  cout << "Yes\n";
  for (int i = 2; i <= n; i++) cout << mark[i] << '\n';
  return 0;
}

Measured memory_bytes: 10276
n = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
A.append(0)

# 総コスト
cost = 0
for i in range(n+1):
    cost += abs(A[i+1] - A[i])


for i in range(n):
    c = cost
    if A[i] < A[i+1] and A[i+1] < A[i+2]:
        print(c)
    elif A[i] > A[i+1] and A[i+1] > A[i+2]:
        print(c)
    else:
        c -= (abs(A[i+1] - A[i]) + abs(A[i+2]-A[i+1])) - abs(A[i+2] - A[i])
        print(c)

Measured memory_bytes: 20584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(n * a > b? b: n*a);
	}
}


Measured memory_bytes: 21588
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static List<String> list = new ArrayList<>();
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		StringBuilder sb = new StringBuilder();
		StringBuilder p = new StringBuilder();
		StringBuilder q = new StringBuilder();

		for(int i = 0; i < n; i++) {
			p.append(scan.next());
			sb.append(i + 1);
		}
		for(int i = 0; i < n; i++) {
			q.append(scan.next());
		}
		sub(sb.toString());

		String strP = p.toString();
		String strQ = q.toString();

		int cntP = 0;
		for(int i = 0; i < list.size(); i++) {
			if(list.get(i).equals(strP)) {
				cntP = i + 1;
				break;
			}
		}

		int cntQ = 0;
		for(int i = 0; i < list.size(); i++) {
			if(list.get(i).equals(strQ)) {
				cntQ = i + 1;
				break;
			}
		}

		System.out.println(Math.abs(cntQ - cntP));
	}
	public static void sub(String target, String ans) {
		if(target.length() <= 1) {
			list.add(ans + target);
		} else {
			for(int i = 0; i < target.length(); i++) {
				sub(target.substring(0,i) + target.substring(1 + i)
				,ans + target.substring(i,i + 1));
			}
		}
	}
	public static void sub(String target) {
		sub(target,"");
	}
}


Measured memory_bytes: 47404
#include <bits/stdc++.h>
using namespace std;
static const int INF = 2000000000;
static const int NIL = -1;
typedef long long ll;
typedef pair<int,int> P;
//#define int ll 



signed main(){
    int n,m,kkk;
    scanf("%d %d %d",&n,&m,&kkk);

    bool ans[n*m+1];

    for(int i=0;i<=n*m;i++) ans[i] = false;

    for(int i=0;i<=n;i++){
        for(int k=0;k<=m;k++){
            ans[i*m+k*n-2*i*k] = true;
        }
    }

    if(ans[kkk]) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
int Dist[1010][1010];
string Grid[1010];
int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
int main()
{
	int N,M,A,B,C,D;
	cin>>N>>M>>A>>B>>C>>D;
	A--;
	B--;
	C--;
	D--;
	for(int i=0;i<N;i++)
		for(int j=0;j<M;j++)
			Dist[i][j]=1e8;
	for(int i=0;i<N;i++)
		cin>>Grid[i];
	queue<int> Q;
	Q.push(A);
	Q.push(B);
	Dist[A][B]=0;
	vector<pi> V;
	for(int dist=0;;dist++)
	{
		bool OK=false;
		for(int i=0;i<(int)(V.size());i++)
			for(int ddx=-2;ddx<=2;ddx++)
				for(int ddy=-2;ddy<=2;ddy++)
				{
					int nx=ddx+V[i].ff,ny=ddy+V[i].ss;
					if(nx>=0&&nx<N&&ny>=0&&ny<M)
						if(Grid[nx][ny]=='.'&&Dist[nx][ny]==1e8)
						{
							OK=true;
							Q.push(nx);
							Q.push(ny);
//							cout<<V[i].first<<" "<<V[i].second<<"->"<<nx<<" "<<ny<<" "<<dist<<"(1)"<<endl;
							Dist[nx][ny]=dist;
						}
				}
		V.resize(0);
		if(!OK&&dist)
			break;
		while(!Q.empty())
		{
			int x=Q.front();
			Q.pop();
			int y=Q.front();
			Q.pop();
			V.pb(mp(x,y));
			for(int i=0;i<4;i++)
			{
				int nx=x+dx[i],ny=y+dy[i];
//				if(x==2)
//					cout<<x<<" "<<y<<" "<<dx[i]<<" "<<i<<" "<<nx<<endl;
//				if(nx==3&&ny==1)
//					cout<<"..."<<Dist[nx][ny]<<endl;
				if(nx<0||nx>=N||ny<0||ny>=M)
					continue;
				if(Dist[nx][ny]!=1e8)
					continue;
				if(Grid[nx][ny]=='#')
					continue;
//				if(nx==3&&ny==1)
//					puts("...");
				Q.push(nx);
				Q.push(ny);
				Dist[nx][ny]=dist;
//				cout<<nx<<" "<<ny<<" "<<dist<<endl;
			}
		}
	}
	if(Dist[C][D]==1e8)
		puts("-1");
	else	cout<<Dist[C][D]<<endl;
	return 0;
}

Measured memory_bytes: 9540
#include<bits/stdc++.h>
#define mod 998244353ll
#define ll long long
using namespace std;
ll mem[3003][3003], ara[3003], s, n;
ll dp(int pos, int sum)
{
    if(sum>s)return 0;
    if(pos==n)return (sum==s);
    if(mem[pos][sum]!=-1)return mem[pos][sum];
    return mem[pos][sum]= (2ll*dp(pos+1, sum)+dp(pos+1, sum+ara[pos]))%mod;
}
int main()
{
    scanf("%lld %lld", &n, &s);
    for(int i=0; i<n; i++)scanf("%lld", &ara[i]);
    memset(mem, -1, sizeof mem);
    printf("%lld\n", dp(0, 0));
    return 0;
}


Measured memory_bytes: 74468
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	static int dp[] = new int[100100];
	static ArrayList<ArrayList<Integer>> edge = new ArrayList<>();
	static ArrayList<Integer> list = new ArrayList<>();

	static ArrayList<Integer> ans = new ArrayList<>();

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int N = Integer.parseInt(str[0]);
		int M = Integer.parseInt(str[1]);

		for (int i = 0; i < N; i++) {
			edge.add(new ArrayList<>());
		}

		for (int i = 0; i < M; i++) {
			str = br.readLine().split(" ");
			int x = Integer.parseInt(str[0]);
			int y = Integer.parseInt(str[1]);
			edge.get(x).add(y);
		}

		for (int i = 0; i < N; i++) {
			visit(i);
		}
		for (int i : ans) {
			System.out.println(i);
		}
	}

	static void visit(int now) {
		if (list.indexOf(now) == -1) {
			list.add(now);
			for (int i : edge.get(now)) {
				visit(i);
			}
			ans.add(0, now);
		}
	}
}



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

void main()
{
	while (1) {
		auto x = readln.chomp.split.map!(to!int);
		if (x[0]+x[1]+x[2] == 0) break;
		auto len = new double[](3);
		len[0] = hypot(x[0], x[1]) / 2;
		len[1] = hypot(x[0], x[2]) / 2;
		len[2] = hypot(x[1], x[2]) / 2;
		auto n = readln.chomp.to!int;
		foreach (i; 0..n) {
			auto r = readln.chomp.to!int;
			bool f;
			foreach (e; len) {
				if (e < r) f = 1;
			}
			if (f) writeln("OK");
			else writeln("NA");
		}
	}
}

Measured memory_bytes: 1056
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main()
{
    int n;
    cin>>n;
    vector<int> p(n),q(n),data(n);
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];
    rep(i,n) data[i]=i+1;
    map<vector<int>,int> mp;
    do
    {
        mp[data]=mp.size();
    }while(next_permutation(data.begin(),data.end()));
    cout<<abs(mp[p]-mp[q]);
}

Measured memory_bytes: 8632
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	s := ReadString()
	m := make(map[byte]bool)
	for _, c := range []byte(s) {
		m[c] = true
	}
	ans := len(s) - 1
	for c, _ := range m {
		t := []byte(s)
		v := 0
		for !ok(t) {
			v++
			for i := 0; i < len(t)-1; i++ {
				if t[i] == c || t[i+1] == c {
					t[i] = c
				}
			}
			t = t[:len(t)-1]
		}
		if ans > v {
			ans = v
		}
	}
	fmt.Println(ans)
}

func ok(t []byte) bool {
	for _, b := range t {
		if b != t[0] {
			return false
		}
	}
	return true
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define INF 10000000

typedef long long ll;
typedef pair<ll, ll> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z


int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

void solve(void){
    int n;
    cin >> n;
    char S[n];
    scanf("%s\n", S);
    bool ans[n]; //t->S,f->W
    bool any_answer = false;
    bool nth;
    int counter = 0;
    while(counter < 4 && !any_answer) {
        switch (counter) {
            case 0: ans[0] = ans[1] = true;
                    if (S[0] == 'o') nth = true; else nth = false;
                    break;
            case 1: ans[0] = true; ans[1] = false;
                    if (S[0] == 'o') nth = false; else nth = true;
                    break;
            case 2: ans[0] = false; ans[1] = true;
                    if (S[0] == 'o') nth = false; else nth = true;
                    break;
            case 3: ans[0] = ans[1] = false;
                    if (S[0] == 'o') nth = true; else nth = false;
                    break;
        }
        Rep(2, n-1, i) {
            if ((S[i-1] == 'o' && ans[i-1]) || (S[i-1] == 'x' && !ans[i-1])) ans[i] = ans[i-2];
            else ans[i] = !(ans[i-2]);
        }
        bool final_flag = (ans[n-1] && S[n-1] == 'o') || (!ans[n-1] && S[n-1] == 'x');
        if ((final_flag && ans[n-2] == ans[0]) || (!final_flag && ans[n-2] != ans[0])) {
            if (ans[n-1] == nth) any_answer = true;
        }
        counter++;
    }
    if (any_answer) {
        rep(n, i) if (ans[i]) putchar('S'); else putchar('W');
        putchar('\n');
    }
    else printf("%d\n", -1);
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N =sc.nextInt();
    int A[] =new int[N];
    for(int i=0;i<N;i++){
      A[i]=sc.nextInt();}
    int ans =0;
    for(int j=0;j<N;j++){
      if(A[A[j]-1]==j+1){ans =ans+1;}}
    System.out.println(ans/2);
  }
}

Measured memory_bytes: 50712
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	s := getNextString(scanner)
	ans := 0
	for i := 1; i < n-1; i++ {
		if s[i-1:i+2] == "ABC" {
			ans++
		}
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
  int N,S,i;
  while(cin>>N,N){
    S=-N;
    for(i=1;i*i<=N;i++){
      if(N%i==0)S+=i+N/i;
      if(i*i==N)S-=i;
    }
    if(N>S)puts("deficient number");
    else if(N<S)puts("abundant number");
    else puts("perfect number");
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  cout << fixed << setprecision(12);
  while(1) {
    int n, sum;
    sum = 0;
    cin >> n;
    if(n == 0)
      break;
    double ave, ans;
    ans = 0;
    int s[n];
    for(int i = 0; i < n; i++) {
      cin >> s[i];
      sum += s[i];
    }
    ave = 1.0 * sum / n;
    for(int i = 0; i < n; i++) {
      ans += (ave - s[i]) * (ave - s[i]);
    }
    cout << sqrt(ans / n) << endl;
  }

  return 0;
}



Measured memory_bytes: 3260
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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

		int n = scan.nextInt();
		int k = scan.nextInt();
		long sum = 0;
		ArrayList<Long> list = new ArrayList<Long>(n);

		for(int i = 0;i < n;i++) {
			list.add(scan.nextLong());
		}

		Collections.sort(list , Collections.reverseOrder());

		if(k >= n) {
			System.out.println(0);
		}else {
			for(int i = 0;i < n;i++) {
				if(k == 0) {
					sum += list.get(i);
				}else {
					k -= 1;
				}
			}

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


Measured memory_bytes: 98532
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int dmx[] = new int[n];
		int dmy[] = new int[m];
		for (int i = 0; i < n; i++) {
			dmx[i] = sc.nextInt();
		}
		for (int i = 0; i < m; i++) {
			dmy[i] = sc.nextInt();
		}
		Arrays.sort(dmx);
		Arrays.sort(dmy);
		boolean b = false;
		for (int i = x + 1; i <= y; i++) {
			if (dmx[n - 1] < i && dmy[0] >= i) {
				b = true;
			}
		}
		if (b) {
			System.out.println("No War");
		} else {
			System.out.println("War");
		}
	}
}


Measured memory_bytes: 21844
import java.util.*;
import java.math.*;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);
	BigInteger bi;

	while(sc.hasNext()){
	    int cnt = 0;
	    for(int i = sc.nextInt(); i >= 1; --i){
		bi = new BigInteger(sc.next());
		if(bi.isProbablePrime(7)) ++cnt;
	    }
	    System.out.printf("%d\n", cnt);
	}
    }

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

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<ll, ll>
#define endl "\n"
#define MAXN 100005
using namespace std;

ll h, w, m, a, b;
vector<ll> v, v1;
unordered_map<ll, ll> r, c;
unordered_map<ll, ll> mm;

void solve()
{
    cin >> h >> w >> m;
    ll mr = 0, mc = 0;
    while (m--)
    {
        cin >> a >> b;
        ll t = a * 1e9 + b;
        mm[t]++;
        r[a]++;
        c[b]++;
        mr = max(mr, r[a]);
        mc = max(mc, c[b]);
    }
    for (ll i = 1; i <= h; i++)
    {
        if (r[i] == mr)
            v.pb(i);
    }
    for (ll i = 1; i <= w; i++)
    {
        if (c[i] == mc)
            v1.pb(i);
    }
    ll ans = 0;
    if (v.size() + v1.size() > 3e5)
    {
        cout << mr + mc << endl;
        return;
    }
    for (ll i = 0; i < v.size(); i++)
    {
        for (ll j = 0; j < v1.size(); j++)
        {
            ll t = v[i] * 1e9 + v1[j];
            if (mm[t] == 1)
                ans = max(ans, r[v[i]] + c[v1[j]] - 1);
            else
                ans = max(ans, r[v[i]] + c[v1[j]]);
        }
    }
    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
}


Measured memory_bytes: 52028
(gets.to_i).times do
    xa,ya,ra,xb,yb,rb=gets.chomp.split(nil).map(&:to_f)
    r=Math::sqrt((xa-xb)**2+(ya-yb)**2)
    if(r+rb)<ra
        puts 2
    elsif(r+ra)<rb
        puts -2
    elsif r<=(ra+rb)
        puts 1
    else
     puts 0
    end
end

Measured memory_bytes: 6140
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n, upper_w;
    cin >> n >> upper_w;
    lint dp[n+1][upper_w+1];
    REP(i, n+1){
        REP(j, upper_w+1){
            dp[i][j] = 0;
        }
    }
    vector<lint> v(n+1, LINF);
    vector<lint> w(n+1, LINF);
    FOR(i, 1, n+1){
        cin >> v[i] >> w[i];
    }
    FOR(i, 1, n+1){
        REP(j, upper_w+1){
            if(j - w[i] >= 0){
                dp[i][j] = max(dp[i-1][j], dp[i-1][j - w[i]] + v[i]);
            }
            else {
                dp[i][j] = dp[i-1][j];
            }
            //cout << dp[i][j] << " ";
        }
        //cout << endl;

    }
    cout << dp[n][upper_w] << endl;
    return 0;
}


Measured memory_bytes: 11056
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int x;
    cin>>x;
    repi(i,1,361){
        if(x*i%360==0){
            cout<<i;
            return 0;
        }
    }
}

Measured memory_bytes: 3604
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cinttypes>
#include <cstdint>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <regex>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;

using Field = vector<vector<ll>>;
using Graph = vector<vector<ll>>;
using VI = vector<int>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VC = vector<char>;
using PI = pair<int, int>;

#define FOR(i, s, n) for (int i = s; i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int N;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> N;
    int n = N % 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon" << endl;
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon" << endl;

    } else {
        cout << "bon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3652
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

vector<int> xs[16];
vector<bool> ys[16];
int main() {
	int N;
	cin >> N;
	for(int i=1;i<=N;i++){
		int A;
		cin >> A;
		for(int j=0;j<A;j++){
			int x,y;
			cin >> x >> y;
			xs[i].push_back(x);
			ys[i].push_back(y==1);
		}
	}

	int ret=0;
	for(int u=0;u<=(1<<(N+1));u+=2){
		bool ok=true;
		int c=0;
		for(int i=1;i<=N&&ok;i++){
			if(!(u&(1<<i)))continue;
			c++;
			for(int j=0;j<xs[i].size();j++){
				int k=xs[i][j];
				if(((u&(1<<k))!=0)!=ys[i][j]){
					/*
					if(u==6){
						cerr << "aaa" << endl;
						cerr << i << ", " << k << ", " << ys[i][j] << endl;
					}
					*/
					ok=false;
					break;
				}
			}
		}
		if(ok){
			ret=max(ret,c);
		}
	}
	cout << ret << endl;

	return 0;
}



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

using ll=long long;
const ll z=0;

int main() {
  string N;
  cin >> N;
  if(N[1]==N[2]){
    if(N[0]==N[1]||N[2]==N[3]){
      cout << "Yes" << endl;
    }
    else
      cout << "No" << endl;
  }
  else
    cout << "No" << endl;
}

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

int main(void){
    int n,k;
    std::cin >> n >> k;

    int mixv = 1;

    for(int i = 0; i < n; i++){
    mixv = std::min(mixv+k,mixv*2);
    }
    std::cout << mixv;
    return 0;
}




Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
char a[100][101];
bool rm_h[100], rm_w[100];
 int main() {
	 int H, W;
	 cin >> H >> W;
	 for (int i = 0; i < H; i++) cin >> a[i];
	 for (int i = 0; i < H; i++) {
		 bool empty = 1;
		 for (int j = 0; j < W; j++) {
			 if (a[i][j] == '#') {
				 empty = 0;
				 break;
			 }
		 }
		 if (empty) rm_h[i] = 1;
	 }
	 for (int i = 0; i < W; i++) {
		 bool empty = 1;
		 for (int j = 0; j < H; j++) {
			 if (a[j][i] == '#') {
				 empty = 0;
				 break;
			 }
		 }
		 if (empty) rm_w[i] = 1;
	 }
	 for (int i = 0; i < H; i++) {
		 if (rm_h[i]) continue;
		 for (int j = 0; j < W; j++) {
			 if (rm_w[j]) continue;
			 cout << a[i][j];
		 }
		 cout << endl;
	 }
}

Measured memory_bytes: 256
//Utkarsh-raj

#include<bits/stdc++.h>

#define ll long long int
#define vc vector
#define mod 100000000007
#define mp make_pair
#define pb push_back
#define nl cout<<endl;
#define ff first
#define ss second

using namespace std;

ll query(ll *BIT, ll idx){
	ll ans = 0;
	while(idx > 0){
		ans = max(ans, BIT[idx]);
		idx -= (idx&(-idx));
	}
	return ans;
}

void update(ll *BIT, ll idx, ll val, int n){
	// cout<<val<<endl;
	ll q = query(BIT, idx-1) + val;
	while(idx <= n){
		BIT[idx] = max(BIT[idx], q);
		idx += (idx&(-idx));
	}
}

int main()
{
	ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    int n;
    cin>>n;

    ll BIT[n+1];
    ll arr[n+1];
    ll val[n+1];

    for(int i=1; i<=n; i++){
    	BIT[i] = 0;
    	cin>>arr[i];
    }
    for(int i=1; i<=n; i++){
    	cin>>val[i];
    }

    BIT[0] = 0;

    for(int i=1; i<=n; i++){
    	update(BIT, arr[i], val[i], n);
    }

    ll ans = query(BIT, n);
    cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 4992
n, k, s =map(int, input().split())

if s == 10 ** 9:
    for i in range(k):
        print(s, end=" ")
    for i in range(n-k):
        print(1, end=" ")
else:
    for i in range(k):
        print(s, end=" ")
    for i in range(n-k):
        print(s+1, end=" ")

Measured memory_bytes: 4212
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char s[300]={};
    int ans=0;
    gets(s);
    for(int i=2;i<strlen(s);i+=2){
        for(int k=0;k<(strlen(s)-i)/2;k++){
            if(s[k]!=s[k+(strlen(s)-i)/2]){
                break;
            }else if(k==(strlen(s)-i)/2-1){
                ans=strlen(s)-i;
                i=strlen(s);
            }
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1604
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	string s1, s2;
	while(cin >> s1 >> s2) {
		int l1 = s1.length();
		int l2 = s2.length();
		vvi dp(l1, vi(l2, 0));
		int ans = 0;
		REP(i, l1) {
			if(s1[i] == s2[0]) {
				dp[i][0] = 1;
			}
		}
		REP(i, l2) {
			if(s2[i] == s1[0]) {
				dp[0][i] = 1;
			}
		}
		FOR(i, 1, l1-1) {
			FOR(j, 1, l2-1) {
				if(s1[i] == s2[j]) {
					dp[i][j] = dp[i-1][j-1]+1;
					ans = max(ans, dp[i][j]);
				}
			}
		}

		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 63836
import numpy as np
import statistics
import itertools

n = int(input())
ls = []
for i in range(n):
    x,y = map(float,input().split())
    ls.append([x,y])
    
al = []
al2 = []


p = 0
for v in itertools.permutations(ls, n):
    al.append(v)
    
for i in range(len(al)):
    ans = 0
    for j in range(n-1):
        ans += np.sqrt((al[p][j+1][0]-al[p][j][0])**2+(al[p][j+1][1]-al[p][j][1])**2)
    al2.append((ans))
    p += 1
    
print(sum(al2)/len(al2))
    

    

Measured memory_bytes: 19488
def main():
  N = int(input())
  a = list(map(int, input().split()))

  c = [0] * (max(a)+3)

  for v in a:
    c[v+1] += 1

  ans = 0

  for i in range(1, len(c) - 1):
    x = c[i-1] + c[i] + c[i+1]
    ans = max(ans, x)

  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 14092
#include<stdio.h>
using namespace std;
int a[1000000],n;
int bin(int q){
    int left=0,righ=n,mid;
    while(left<righ){
        mid=(left+righ)/2;
        if(a[mid]==q){
            return 1;
        }
        else{
            if(q<a[mid]){
                righ=mid;
            }else{
                if(q>a[mid]){
                    left=mid+1;
                }
            }
        }
    }
    return 0;
}
int main(){
    int q,sum=0,b;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d",&b);
        if(bin(b))sum++;
    }
    printf("%d\n",sum);
return 0;
}

Measured memory_bytes: 2956
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
  int a,b;

  cin >> a >> b;

  if(a<b){
      for(int i = 0;i < b;i++){
          cout << a;
      }
  }else{
      for(int i = 0;i < a;i++){
          cout << b;
 	 }
  }

}
   


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


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

    bool exp[1001] = {false};
    exp[1] = true;
    for(int b=2; b<=31; b++) {
        for(int p=2; p<=9; p++) {
            int e = pow(b, p);
            if(e <= 1000) {
                exp[e] = true;
            } else {
                break;
            }
        }
    }

    for(int x = X; x>=1; x--) {
        if(exp[x] == true) {
            cout << x << endl;
            break;
        }
    }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  if(A * N < B){
    cout << A * N << endl;
  }
  else if(B < A * N){
    cout << B << endl;
  }
  else{
    cout << B << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int head, tail, n, q;
const int MAX = 100010;

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

P Q[MAX];

void initialize() { head = tail = 0; }

bool isEmpty() { return head == tail; }

bool isFull() { return head == (tail + 1) % MAX; }

void enqueue(P x)
{
    Q[tail] = x;
    tail = (tail + 1) % MAX;
}

P dequeue()
{
    P x = Q[head];
    head = (head + 1) % MAX;
    return x;
}

int main()
{
    ios_base::sync_with_stdio(false);
    int elaps = 0, min_num;
    P q_ele;
    cin.tie(0);
    // input
    cin >> n >> q;
    rep(i, n)
    {
        string name;
        int time;
        cin >> name >> time;
        Q[i].n = name;
        Q[i].t = time;
    }
    // output
    head = 0, tail = n;
    while (head != tail) {
        q_ele = dequeue();
        min_num = min(q, q_ele.t);
        q_ele.t -= min_num;
        elaps += min_num;
        if (q_ele.t > 0) {
            enqueue(q_ele);
        } else {
            cout << q_ele.n << " " << elaps << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 7084
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
using namespace std;

const int RATE = 380000;

int main(){

    int n;
    cin >> n;

    double x;
    string s;
    double sum = 0.0;
    for(int i=0; i<n; i++){
        cin >> x >> s;

        if(s == "JPY"){
            sum += x;
        }
        else{
            sum += x * RATE;
        }
    }

    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 384
X,Y = map(int,input().split())
ans = 0
ans += 100000 if X == 3 else 0
ans += 100000 if Y == 3 else 0
ans += 200000 if X == 2 else 0
ans += 200000 if Y == 2 else 0
ans += 300000 if X == 1 else 0
ans += 300000 if Y == 1 else 0
ans += 400000 if X == 1 and Y == 1 else 0
print(ans)


Measured memory_bytes: 38384
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    long[] c = new long[n+1];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      c[a[i]]++;
    }

    long sum = 0;

    for (int i = 0; i < n+1; i++) {
      sum += res(c[i]);
    }

    for (int i = 0; i < n; i++) {
      System.out.println(sum-(c[a[i]]-1));
    }

  }

  public static long res (long c) {
    long ans = c*(c-1)/2;
    return ans;
  }

}


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

int main() { 
  int n;
  cin >> n;
  vector<string> S(n);
  rep(i,n) cin >> S[i];
  vector<int> a(26, 50);
  rep(i,n) {
    map<char, int> mp;
    rep(j, S[i].length()) {
      mp[S[i][j]]++;
    }
    rep(j, 26) {
      a[j] = min(a[j], mp['a'+j]);
    }
  }
  string ans = "";
  rep(i,26) {
    string temp(a[i], 'a'+i);
    ans += temp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
import numpy as np
N,M=input().split()
N=int(N)
M=int(M)

l=np.array([1 for i in range(M)])
for i in range(N):
	tmp=input().split()
	K=int(tmp[0])
	
	prefer=np.array([0 for j in range(M)])
	for k in range(K):
		prefer[int(tmp[k+1])-1]=1
	l*=prefer
print(np.sum(l))




Measured memory_bytes: 12444
import kotlin.math.*

fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toInt() }

    val m_r = m * 6
    val h_r = (h * 360 + m_r) / 12f

    val d = sqrt(a * a + b * b- 2 * a* b * cos((h_r - m_r) * PI / 180))

    println(d)
}

Measured memory_bytes: 36612
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
    int inf=1000000000,x,i1,i2,j1,j2,ans=0,n,i;
     long double d;
     int a[47][21];
     cin>>n;
     memset(a,0,sizeof(a));
     for(i=1;i<=n;i++){
         cin>>d;
         i1=0,i2=0;
         x=(int)(round(d*1e9));
         while(x%2==0){x/=2;i1++;}
         while(x%5==0){x/=5,i2++;}
         a[i1][i2]++;
     }
     for(i1=0;i1<=45;i1++){
         for(j1=0;j1<=20;j1++){
             for(i2=0;i2<=45;i2++){
                 for(j2=0;j2<=20;j2++){
                     if(i2<i1||(i2==i1&&j1>j2))continue;
                     if(min(i1+i2,j1+j2)>=18){if(i1==i2&&j1==j2){x=a[i1][j1];
                         ans+=(x*(x-1))/2;continue;
                     }
                         ans+=a[i1][j1]*a[i2][j2];}
                 }
             }
         }
     }
     cout<<ans;
    return 0;
}

Measured memory_bytes: 3688
use proconio::{input, fastout};
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input! {
        n: usize,
        mut aa: [usize; n],
    }

    aa.sort();
    aa.reverse();
    let mut sum = 0;
    let mut heap = BinaryHeap::new();

    let first = aa[0];
    for a in aa.into_iter().skip(1) {
        if let Some((x, y)) = heap.pop() {
            sum += x;
            heap.push((a, x));
            heap.push((a, y));
        } else {
            sum += first;
            heap.push((a, first));
            heap.push((a, first));
        }
    }
    println!("{}", sum);
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

typedef ll number;
typedef vector<number> arr;
typedef vector<arr> matrix;  
const ll INF = (1ll<<60);
matrix WarhshallFloyd_matrix(const matrix &G){
    // Gの要素は対角が0, 辺のあるところが辺の重み，辺のないところがINF
    // 負閉路はDの対角要素が負かどうかで判定可能
    // 負辺がある場合の到達不能判定に注意！（D[i][j] > INF/2 とかにする必要あり）
	int V = G.size();
    matrix D(V, arr(V));

    for(int i=0;i<V;i++){
        for(int j=0;j<V;j++){
            D[i][j] = G[i][j];
        }
    }

	for(int k=0;k<V;k++){
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
			}
		}
	}
	return D;
}

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

    ll N;
    cin >> N;
    vector<ll> a(N), b(N);
    REP(i, N) cin >> a[i];
    REP(i, N) cin >> b[i];

    vector<ll> need;
    for(int i=50;i>=1;i--){
    	matrix G(51, arr(51, INF));
    	for(int j=0;j<51;j++) G[j][j] = 0;

    	for(int j=50;j>=1;j--){
    		for(int k=1;k<i;k++){
    			G[j][j%k] = 1;
    		}
    		for(int k=0;k<(int)need.size();k++){
    			G[j][j%need[k]] = 1;
    		}
    	}

    	auto d = WarhshallFloyd_matrix(G);
    	bool ok = true;
    	for(int i=0;i<N;i++){
    		if(d[a[i]][b[i]]>=INF) ok = false;
    	}

    	if(!ok) need.push_back(i);
    }

    ll res = 0;
    REP(i, need.size()){
    	res += (1ll<<need[i]);
    }
    if((int)need.size()==50) cout << -1 << endl;
    else cout << res << endl;
    return 0;
}

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

int main(){
  long long int a[3];
  cin >> a[0] >> a[1] >> a[2];
    if(a[0]%2==0||a[1]%2==0||a[2]%2==0){
      cout << 0 << endl;
      }
    else{
      sort(a,a+3);
      cout << a[0]*a[1] << endl;
      }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for(int i=0;i<n;i++){
    cin >> A.at(i) ;
  }
  map<int,int> dic;
  for(int i=0;i<n;i++){
    if(dic.count(A.at(i))){
      dic[A.at(i)] ++;
    }else{
      dic[A.at(i)] = 1;
    }
  }
  int ans = 0;
  for(auto p:dic){
    if(p.first < p.second){
      ans += p.second - p.first;
    }else if(p.first > p.second){
      ans += p.second;
    }
  }
  cout << ans <<endl;
}
      




Measured memory_bytes: 5120
import sys
k = int(input())

def a(n):
    t = n * 10 + 7
    return t % k

a_i = 7
i = 1
if a_i % k == 0:
    print(i)
    sys.exit()

for j in range(k+1):
    a_i = a(a_i)
    i += 1
    if a_i % k == 0:
        print(i)
        sys.exit()
print(-1)


Measured memory_bytes: 9072
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <string.h>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k, ans = 0;
	cin >> n >> k;
	while (n > 0) {
		ans++;
		n /= k;
	}
	cout << ans;
}



Measured memory_bytes: 256
n = int(input())
txy = [[0,0,0]]
for i in range(n):
    txy.append(list(map(int,input().split())))
ans = True

for i in range(n):
    time = abs(txy[i][0] - txy[i+1][0])
    dis = abs(txy[i][1] - txy[i+1][1]) + abs(txy[i][2] - txy[i+1][2])
    if time % 2 == dis % 2:
        if dis % 2 == 0:
            if dis == 0 or dis == time:
                continue
            else:
                ans = False
                break
        else:
            if dis == 1 or dis == time:
                continue
            else:
                ans = False
                break
    else:
        ans = False
        break
    
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 27300
# 問題文読み違えてた
# 同じのが隣り合ったらダメ
# 数が同じ -> 交互に並べる
# 差が1 -> 大きいほうが外側両端をとる
# 差がそれ以上 -> はいどうしたって無理
n, m = map(int, input().split())
if n == m:
    ans = 2  # 同じ数なので入れ替えたときのやつ
    for i in range(2, n+1):
        ans *= i
        ans %= 10**9+7
        ans *= i
        ans %= 10**9+7
    print(ans)
elif abs(n - m) == 1:
    ans = 1
    for i in range(2, n+1):
        ans *= i
        ans %= 10**9+7
    for i in range(2, m+1):
        ans *= i
        ans %= 10**9+7
    print(ans)
else:
    print(0)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	cin>>s;
  	for(int i=0;i<s.length();i++){
    	if(s[i]!=s[s.length()-i-1]){
        	cout<<"No";return 0;
        }
    }
  	cout<<"Yes";
}

Measured memory_bytes: 256
def check(si, xs, checked):
    q = [si]
    while q:
        i = q.pop()
        xi = xs[i]
        for j, d in links[i]:
            if checked[j]:
                continue
            if j not in xs:
                xs[j] = xi + d
            elif xi + d != xs[j]:
                return False
            q.append(j)
        checked[i] = True
    return True


def solve():
    checked = [False] * n
    for i in range(n):
        if not checked[i]:
            xs = {}
            xs[i] = 0
            if not check(i, xs, checked):
                return False
    return True


n, m = map(int, input().split())
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print('Yes' if solve() else 'No')


Measured memory_bytes: 93544
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

bool is_palindrome(std::string str)
{
    for (int i = 0; i < str.length() / 2; i++) {
        if (str[i] != str[str.length() - 1 - i]) {
            return false;
        }
    }
    return true;
}

int main()
{
    std::string s;
    std::cin >> s;

    std::cout << ((is_palindrome(s) && is_palindrome(s.substr(0, (s.length() - 1) / 2)) && is_palindrome(s.substr((s.length() + 3) / 2 - 1, (s.length() - 1) / 2))) ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define chmax(a,b) if(a<b)a=b;
#define chmin(a,b) if(b<a)a=b;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
vector<pii> st;
void getLargestRectangle() {
	int H, W; cin >> H >> W;
	vv(int, v, H, W, 0);
	int x;
	rep(i, 0, H) rep(j, 0, W) {
		cin >> x;
		v[i][j] = !x;
	}
	rep(i, 0, H - 1) rep(j, 0, W) if(v[i + 1][j] != 0) v[i + 1][j] += v[i][j];
	int ans = 0, pos;
	rep(i, 0, H) {
		st.clear();
		st.eb(0, 0);
		rep(j, 0, W) {
			if (st.back().fi == v[i][j]) continue;
			pos = j;
			while (st.back().fi > v[i][j]) {
				chmax(ans, st.back().fi * (j - st.back().se));
				pos = st.back().se; st.pop_back();
			}
			st.eb(v[i][j], pos);
		}
		while (!st.empty()) {
			chmax(ans, st.back().fi * (W - st.back().se));
			st.pop_back();
		}
	}
	P(ans);
}
int main() {
	getLargestRectangle();
	return 0;
}

Measured memory_bytes: 10384
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,same=0;
	cin>>n;
	vector<string>t(n);
	for(int i=0;i<n;i++)	cin>>t.at(i);
	sort(t.begin(),t.end());
//	for(int i=0;i<n;i++)	cout<<t.at(i)<<endl;
	for(int i=0;i<n-1;i++){
		if(t.at(i)==t.at(i+1)) same++;
	}
	cout<<(n-same)<<endl;
	return 0;
}


Measured memory_bytes: 9524