akhauriyash/Code-Regression huggingface dataset:
package main

import (
        "fmt"
)

func solution(n int) int {
        memo := make([]int, n+1)

        for i := 1; i < n+1; i++ {
                for j := 0; j < n+1; j++ {
                        if j%i == 0 {
                                memo[j]++
                        }
                }
        }
        out := 0
        for i := 1; i < n+1; i = i + 2 {
                if memo[i] == 8 {
                        out++
                }
        }
        return out
}

func main() {
        var n int
        fmt.Scan(&n)
        fmt.Println(solution(n))
}

Measured memory_bytes: 1776
using AtCoderBeginnerContest152.Questions;
using AtCoderBeginnerContest152.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest152.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var ab = inputStream.ReadIntArray();

            var a = string.Concat(Enumerable.Repeat(ab[0].ToString(), ab[1]));
            var b = string.Concat(Enumerable.Repeat(ab[1].ToString(), ab[0]));

            yield return a.CompareTo(b) <= 0 ? a : b;
        }
    }
}


namespace AtCoderBeginnerContest152
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest152.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest152.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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


#define long long long int

using namespace std;


typedef vector<int> vi;
typedef pair<int, int> pi;

void print(const vector<long> &a) {
    for (auto item : a) {
        cout << item << " ";
        flush(cout);
    }
}



int main() {

    int a, b;
    cin >> a >> b;

    if (a > 9 or b > 9){
        cout << -1;
    } else {
        cout << a * b;
    }


    return 0;
}

Measured memory_bytes: 256
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));

  $o = true;
  $e = true;
  for ($i=0; $i<strlen($s); $i++) {
    if($i % 2 == 0){
      if($s[$i] == 'L') $o = false;
    }else{
      if($s[$i] == 'R') $e = false;      
    }
  }

  echo $o && $e ? 'Yes' : 'No';
 

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

ph = {}
for i in range(N):
    s,l,p = map(int,input().split())
    for j in range(s,l+1):
        if j not in ph:
            ph[j] = p
        else:
            ph[j] = max(p, ph[j])

M = int(input())
melody = []
for i in range(M):
    melody.append(int(input()))

#print(ph)
phrase = [0 for i in range(393+1)]
for k,p in ph.items():
    for j in range(k,393+1):
        if phrase[j] < phrase[j-k] + p:
            phrase[j] = phrase[j-k] + p

ans = [phrase[i] for i in melody if phrase[i]]
if len(ans) == M:
    [print(i) for i in ans]
else:
    print(-1)


Measured memory_bytes: 5732
/*
  author : Anand
*/

#include <bits/stdc++.h>

using namespace std;

#define PI 3.1415926535897932384626
#define int long long
#define ll long long

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string) s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

// #define LOCAL

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int INF = 1e18 + 5;
const int MOD = 1000000007;


signed main() {
	cin.tie(nullptr);
	std::ios::sync_with_stdio(false);

	int n;
	cin >> n;
	unordered_set<string> S;
	while(n--) {
		string s;
		cin >> s;
		S.insert(s);
	}
	cout << S.size() << '\n';

	return 0;
}

Measured memory_bytes: 17696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		int[] kuro=new int[N+2];
		int[] siro=new int[N+2];
		String isi=sc.next();
		Arrays.fill(kuro, 0);
		Arrays.fill(siro, 0);
		for(int i=0; i<N; i++) {
			if(isi.charAt(i)=='.') {
				siro[i+1]++;
			}
			else {
				kuro[i+1]++;
			}
		}
		for(int i=1; i<=N; i++) {
			kuro[i]=kuro[i-1]+kuro[i];
			siro[i]=siro[i-1]+siro[i];
		}
		kuro[N+1]=kuro[N];
		siro[N+1]=siro[N];
		int min=1_000_000_007;
		for(int i=1; i<=N; i++) {
			min=Math.min(min, kuro[i]+siro[N+1]-siro[i]);
		}
		min=Math.min(min, kuro[N+1]);
		min=Math.min(min, siro[N+1]);
		pl(min);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 26708
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


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

  ll W, H, N;
  cin >> W >> H >> N;

  ll left = 0;
  ll right = W;
  ll bottom = 0;
  ll top = H;
  REP(i, N){
    ll x, y, a;
    cin >> x >> y >> a;
    if (a==1){
      left = max(left, x);
    } else if (a==2){
      right = min(right, x);
    } else if (a==3){
      bottom = max(bottom, y);
    } else {
      top = min(top, y);
    }
  }

  ll ans = 0;
  if (left < right && bottom < top){
    ans = (right-left) * (top-bottom);
  }

  cout << ans << "\n";
  return 0;
}


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

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

  string S;
  for (int i = 1; i <= N; i++) {
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i == N ) {
    cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
char teamName[10][21];
int points[10];
int indexs[10];
void solve(int N) {
	int I, x, y, z;
	int i, j, swp;
	for(I = 0; I < N; ++ I) {
		scanf("%s %d %d %d", teamName[I], &x, &y, &z);
		points[I] = 3 * x + z;
		indexs[I] = I;
	}
	for(i = 0; i < N; ++ i) {
		for(j = i; j < N; ++ j) {
			if(points[i] < points[j] || (points[i] == points[j] && indexs[i] > indexs[j])) {
				swp = points[i];
				points[i] = points[j];
				points[j] = swp;
				swp = indexs[i];
				indexs[i] = indexs[j];
				indexs[j] = swp;
			}
		}
	}
}
int main() {
	int i, N;
	scanf("%d", &N);
	solve(N);
	for(i = 0; i < N; ++ i) printf("%s,%d\n", teamName[indexs[i]], points[i]);
	while(1) {
		scanf("%d", &N);
		if(N == 0) break;
		printf("\n");
		solve(N);
		for(i = 0; i < N; ++ i) printf("%s,%d\n", teamName[indexs[i]], points[i]);
	}
	return 0;
}

Measured memory_bytes: 604
fun main(args: Array<String>) {
    abc116b()
}

fun abc116b() {
    val s = readLine()!!.toLong()

    val list = arrayListOf(s)
    var i = 1
    while (true) {
        val before = list[i++ - 1]
        val curr = if (before % 2 == 0L) before / 2 else 3 * before + 1

        if (list.contains(curr)) return println(i)

        list.add(curr)
    }
}


Measured memory_bytes: 33528
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    int d=0;
    for(int i=a;i<=b;i++){
      if(c%i==0) d++;
    }
    System.out.println(d);
  }
}



Measured memory_bytes: 26208
function Main(input) {
  input = input.split("\n");
  var num = parseInt(input[0], 10);
  var stones = input[1].split("");
  var reds = 0, whites =0;
  for (var i=0; i<num; i++) {
    if (stones[i] === "R") {
      reds += 1;
    } else {
      whites += 1;
    }
  }
  var counter = 0;
  for (var i=reds; i<num; i++) {
    if (stones[i] === "R") {
      counter += 1;
    }
  }
  console.log(counter);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

void main_()
{
    string S;
    cin >> S;

    string ans;
    for (auto ch : S) {
        if (ch == '0' || ch == '1') {
            ans.append(1, ch);
        }
        if (ch == 'B' && !ans.empty()) {
            ans.pop_back();
        }
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        q: usize,
        s: chars,
        lr: [[usize; 2]; q],
    }

    let mut t: Vec<usize> = vec![0;n+2];
    for i in 0..n-1 {
        if s[i]=='A' && s[i+1]=='C' {
            t[i+1] = t[i] + 1;
        } else {
            t[i+1] = t[i];
        }
        // println!("{}", t[i]);
    }

    for i in 0..q {
        println!("{}", t[lr[i][1]-1] - t[lr[i][0]-1]);
    }

}

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

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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

// ***************************************

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};


int main(){

    int N, M, K;
    cin >> N >> M >> K;

    UnionFind uf(N);
    vector<int> no(N, 0);

    int a, b;
    REP(i, M) {
        cin >> a >> b; a--; b--;
        uf.merge(a, b);
        no[a]++; no[b]++;
    }

    REP(i, K) {
        cin >> a >> b;
        a--; b--;
        if (uf.issame(a, b)) {
            no[a]++;
            no[b]++;
        }
    }

    REP(i, N) {
        cout << uf.size(i) - no[i] - 1;
		if (i < N - 1) {
			cout << " ";
		}
    }
    cout << endl;


	return 0;
}

Measured memory_bytes: 1664
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	
	if(n%2==1){
			puts("No");
			return 0;
	}
	
	for(int i=0; i<n/2; i++)
		if(s[i]!=s[i+n/2]){
			puts("No");
			return 0;
		}
	
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
INF = float('inf')

N, capW = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(N)]

sumV = 10**5
dp = [INF] * (sumV+1)
dp[0] = 0
for wi, vi in items:
    for v in reversed(range(sumV+1)):
        if dp[v] == INF: continue
        dp[v+vi] = min(dp[v+vi], dp[v] + wi)

print(max([v for v in range(sumV+1) if dp[v] <= capW]))


Measured memory_bytes: 62924
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
q = int(input())

count_a = Counter(a)
ans = sum(a)

for _ in range(q):
    b, c = map(int, input().split())
    if b in count_a:
        ans += (c - b) * count_a[b]
        if c not in count_a:
            count_a[c] = 0
        count_a[c] += count_a[b]
        count_a[b] = 0
        print(ans)
    else:
        print(ans)

Measured memory_bytes: 21396
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int64 modInverse(const int64 a,const int mod){
  int n=mod-2;
  int64 t=1;
  int64 s=a;
  while(n>0){
    if(n&0x01) t=t*s%mod;
    s=s*s%mod;
    n>>=1;
  }
  return t;
}

void run(void){
  int64 n,a,b;
  int64 k;
  scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
  const int mod=998244353;
  int64 *comb=(int64 *)malloc(sizeof(int64)*(n+1));
  comb[0]=1;
  int i;
  for(i=1;i<=n;i++){
    comb[i]=comb[i-1]*(n+1-i)%mod*modInverse(i,mod)%mod;
  }
  int64 way=0;
  for(i=0;i<=n;i++){
    if(!(k-a*i>=0 && (k-a*i)%b==0 && (k-a*i)/b<=n)) continue;
    int j=(k-a*i)/b;
    way=(way+comb[i]*comb[j])%mod;
  }
  printf("%lld\n",way);
  return;
}

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


Measured memory_bytes: 2560
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

h,w = inm()
a = []
seq = []
for i in range(h):
    a.append(inl())
for i in range(h):
    for j in range(w-1):
        if a[i][j]%2==1:
            seq.append((i,j,i,j+1))
            a[i][j+1] += 1
    if a[i][w-1]%2==1 and i<h-1:
        seq.append((i,w-1,i+1,w-1))
        a[i+1][w-1] += 1
print(len(seq))
for z in seq:
    print("{} {} {} {}".format(z[0]+1,z[1]+1,z[2]+1,z[3]+1))


Measured memory_bytes: 64732
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int[] num = new int[3];
		int a = 0;
		int b = 0;
		int c = 0;
		int d = 0;

		while (scanner.hasNext()) {
			for (int i = 0; i < 3; i++)
				num[i] = scanner.nextInt();
			Arrays.sort(num);
			if (num[0] + num[1] <= num[2]) {
				System.out.printf("%d %d %d %d\n", a, b, c, d);
				return;
			}
			a++;
			int na = num[0] * num[0];
			int nb = num[1] * num[1];
			int nc = num[2] * num[2];
			if (na + nb == nc)
				b++;
			else if (na + nb > nc)
				c++;
			else
				d++;
		}
	}
}

Measured memory_bytes: 20532
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, d,n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S, T, U; bool check = true;	priority_queue<ll,vector<ll>,greater<ll> > v;

ll BFS(ll n) {
	while (1) {
		b = v.top();
		d = b % 10;
		if (d - 1 >= 0)v.push(b * 10 + (d - 1));
		v.push(b * 10 + d);
		if(d + 1 <= 9)v.push(b * 10 + (d + 1));
		a++;
		
		if (a == n) { c = v.top(); break; }
		v.pop();
	}


	return 0;
}

int main() {
	//Code Line
	cin >> n;
	for (int i = 1; i < 10; i++) {
		v.push(i);
	}
	BFS(n);
	cout << c;

	
	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin>>N;
  vector<long long> vc(N,0);
  long long a;
  for (long long i=0;i<N-1;i++){
    cin>>a;
    vc[a-1]++;
  }
  for (long long i=0;i<N;i++){
    cout<<vc[i]<<endl;
  }
}


Measured memory_bytes: 4776
#include<stdio.h>
int main(){
    int n,k,x,y;
    scanf("%d %d %d %d",&n,&k,&x,&y);
    long long int r;
    if(n>=k) r=k*x+(n-k)*y;
    else r=n*x;
    printf("%lld\n",r);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  double r;
  cin >> r;
  double ans = 2*M_PI*r;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3792
#include<stdio.h>

int main() {
    int i, n, q, S[10000], T[5000], C=0;

    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%d", &S[i]);
    scanf("%d", &q);
    for (i=0; i<q; i++) scanf("%d", &T[i]);
    
    for (i=0; i<q; i++) {
        for (int j=0; j<n; j++) {
            if (T[i]==S[j]) {
                C++;
                break;
            }
        }
    }
    printf("%d\n", C);
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	LL n;
	cin >> n;
	if (n%2) {
		cout << 0 << endl;
		return 0;
	}
	LL ans = 0;
	n /= 2;
	while (n > 0) {
		 n/= 5;
		 ans += n;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A,B,C = map(int,read().split())

answer = 0
# C,B,C,B,...
x = min(B,C)
answer += x + x
B -= x
C -= x
if B:
    answer += B
else:
    # C,A,C,A,
    x = min(C,A+1)
    answer += x
print(answer)

Measured memory_bytes: 3064
/*input
1 6 4
1 1 1 6
......
*/

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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 1e9
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define UQ(x) (x).resize(distance((x).begin(),unique(all((x)))))

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd64(chrono::high_resolution_clock::now().time_since_epoch().count());

ll power(ll a,ll m,ll mod){
    ll ans=1;
    while(m){
        if(m%2){
            ans*=a;
            ans%=(mod);
        }
        a=(a*a)%(mod);
        m>>=1;
    }
    return ans;
}


void init(ll* a,ll n,ll val){
    for(ll i=0;i<n;i++)
        a[i]=val;
}

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

void solve(){
    ll i,j,_;
    ll h,w,k,x,y;
    cin>>h>>w>>k;
    char ch;
    ll x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2,--x1,--x2,--y1,--y2;
    ll a[h][w];
    ll b[h][w];
    rep(i,0,h){
        rep(j,0,w){
            cin>>ch;
            a[i][j]=(ch=='.');
            b[i][j]=inf;
        }
    }
    if(!a[x1][y1]||!a[x2][y2]){
        cout<<-1<<endl;
        return;
    }
    b[x1][y1]=0;
    list<pll> queue;
    queue.pb({x1,y1});
    while(!queue.empty()){
        pll z=queue.front();
        queue.pop_front();
        rep(i,0,4){
            x=z.F,y=z.S;
            rep(j,0,k){
                x+=dx[i],y+=+dy[i];
                if(x<0||y<0||x>h-1||y>w-1||!a[x][y])break;
                if(b[x][y]<b[z.F][z.S]+1)break;
                if(b[x][y]<inf)continue;
                b[x][y]=b[z.F][z.S]+1;
                queue.pb({x,y});
            }
        }
    }
    // rep(i,0,h){
    //     rep(j,0,w)cout<<b[i][j]<<' ';cout<<endl;
    // }
    cout<<((b[x2][y2]==inf)?-1:b[x2][y2])<<endl;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll T=1;
   // cin>>T;
    while(T--){
        solve();
    }
    return 0;
}




Measured memory_bytes: 24812
import math
X=0
Y=0
th=0
while 1:
  d,a=list(map(int,input().split(",")))
  if not a and not d:break
  Y+=d*math.cos(math.radians(th))
  X+=d*math.sin(math.radians(th))
  th+=a
print(int(X))
print(int(Y))


Measured memory_bytes: 5708
/* 
 * Project: AtCoder Beginners Contest 158 A - Station and Bus
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/03/07
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string s;

void solve() {

    bool condition = false; 
    for (int i=0;i<3;i++) {
        if (s[i] == 'A') {
            for (int j=0;j<3;j++) {
                if (s[j] == 'B')
                    condition = true;
            }
        } else if (s[i] == 'B') {
            for (int j=0;j<3;j++) {
                if (s[j] == 'A')
                    condition = true;
            }
        }
    }
    if (condition)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main() {

    cin >> s;

    solve();

}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int N, A, B;
  scanf("%d %d %d", &N, &A, &B);
  if (N*A >= B) {
    printf("%d\n", B);
  } else {
    printf("%d\n", N*A);
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;

ll dp[51][2501];

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

    dp[0][0] = 1;
    for(int i=0; i<v.size(); ++i) {
        for(int j=49; j>=0; --j) {
            for(int k=0; k<=2500-v[i]; ++k) {
                dp[j+1][k+v[i]] += dp[j][k];
            }
        }
    }
    ll ret = 0;
    for(int i=1; i<=50; ++i) {
        ret += dp[i][i*a];
    }
    cout << ret << endl;
}


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
typedef long long ll;

ll d[10][10];

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int r = i % 10;
        int l = i;
        while(l >= 10) l /= 10;
        d[l][r]++;
    }
    ll ans = 0;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            ans += d[i][j] * d[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define INF 5300000
int main(){
  int t,i,n,p[500],m[500][500],minm=INF,l=0,j=0,k=0,q=0;
  scanf("%d",&n);/*nは行列の数*/
  for(i=0;i<n;i++){
    scanf("%d%d",&p[i],&p[i+1]);
  }
  for(i=1;i<=n;i++){
    m[i][i]=0;
    
  }
  for(l=2;l<n+1;l++){

    for(i=1;i<n-l+2;i++){
      j=i+l-1;
      m[i][j]=INF;

     for(k=i;k<j;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
     
	if(q<=m[i][j]){
	  m[i][j]=q;

	}
      }
    }}
  printf("%d\n",m[1][n]);
  return 0;
}

Measured memory_bytes: 796
formula = input().split()
stack = []
for f in formula:
    if f in ["+", "-", "*"]:
        if f == "+":
            s = stack[-2] + stack[-1]
        elif f == "-":
            s = stack[-2] - stack[-1]
        else:
            s = stack[-2] * stack[-1]
        stack.pop(-1)
        stack.pop(-1)
        stack.append(s)
    else:
        stack.append(int(f))

print(stack[0])


Measured memory_bytes: 5600
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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


N,X = inpl()
mm = [int(input()) for i in range(N)]

X -= sum(mm)
print( N + X // min(mm) )

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

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

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

#define	MOD 1000000007

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

int	main() {
	int H, W;
	cin >>H >>W;
	int CH, CW, DH, DW;
	cin >>CH >>CW >>DH >>DW;
	vector<vector<int>> M(H+2, vector<int> (W+2, -1));
	Rep1(i, H) {
		string S;
		cin >>S;
		Rep1(j, W) {
			if ('.'==S.at(j-1))
				M.at(i).at(j)=INF;
		}
	}
	M.at(CH).at(CW)=0;
	priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;
	q.push({0, CH, CW});
	while(!q.empty()) {
		int c=q.top().at(0);
		int x=q.top().at(1);
		int y=q.top().at(2);
		q.pop();
		if (x>1) {
			if (M.at(x-1).at(y)>c) {
				M.at(x-1).at(y)=c;
				q.push({c, x-1, y});
			}
		}
		if (x<H) {
			if (M.at(x+1).at(y)>c) {
				M.at(x+1).at(y)=c;
				q.push({c, x+1, y});
			}
		}
		if (y>1) {
			if (M.at(x).at(y-1)>c) {
				M.at(x).at(y-1)=c;
				q.push({c, x, y-1});
			}
		}
		if (y<W) {
			if (M.at(x).at(y+1)>c) {
				M.at(x).at(y+1)=c;
				q.push({c, x, y+1});
			}
		}
		c++;
		for (int i=x-2; i<=x+2; i++) {
			if ((i<1)||(H<i))
				continue;
			for (int j=y-2; j<=y+2; j++) {
				if ((j<1)||(W<j))
					continue;
				if (M.at(i).at(j)>c) {
					M.at(i).at(j)=c;
					q.push({c, i, j});
				}
			}
		}
	}
	if (M.at(DH).at(DW)==INF)
		M.at(DH).at(DW)=-1;
	cout <<M.at(DH).at(DW) <<endl;
	return 0;
}



Measured memory_bytes: 8004
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, A, B, C = map(int, input().split())
    l = [int(input()) for _ in range(N)]
    INF = 10 ** 9

    def dfs(cursor, a, b, c):
        if cursor == N:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF

        no_compound_pattern = dfs(cursor+1, a, b, c)
        compound_a_pattern = dfs(cursor+1, a + l[cursor], b, c) + 10
        compound_b_pattern = dfs(cursor+1, a, b + l[cursor], c) + 10
        compound_c_pattern = dfs(cursor+1, a, b, c + l[cursor]) + 10

        return min(no_compound_pattern, compound_a_pattern, compound_b_pattern, compound_c_pattern)

    print(dfs(0, 0, 0, 0))


if __name__ == '__main__':
    main()


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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var item = new List<int>();

            for(var x=0; x<n; ++x)
            {
                var price = int.Parse(Console.ReadLine());
                item.Add(price);
            }

            var m = item.Max();
            item.Remove(m);

            var sum = 0;
            foreach(var ch in item)
            {
                sum += ch;
            }
            Console.WriteLine(sum + m / 2);
        }
        
    }
}


Measured memory_bytes: 13152
gets
s = gets.chomp

collect = ''
opened = 0
s.each_char do |b|
  case b
  when '('
    opened += 1
    collect += b
  else
    opened -= 1
    if opened < 0
      collect = '('+ collect + b
      opened = 0
      next
    end
    collect += b
  end
end
print collect + (')' * opened)


Measured memory_bytes: 3836
N, M = map(int, input().split())
H_list = list(map(int, input().split()))
route_list = [list(map(int, input().split())) for m in range(M)]
frag_N = [True for i in range(N)]

for A, B in route_list:
    if H_list[A-1] < H_list[B-1]:
        frag_N[A-1] = False
    elif H_list[A-1] > H_list[B-1]:
        frag_N[B-1] = False
    else:
        frag_N[A-1] = False
        frag_N[B-1] = False

print(frag_N.count(True))


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

int main() {
  int N;
  cin >> N;
  pair<pair<string, int>, int> pairs[N];
  for (int i = 0; i < N; i++) {
    string city;
    int score;
    cin >> city >> score;
    pairs[i] = make_pair(make_pair(city, -score), i);
  }


  sort(pairs, pairs + N);
  for (int i = 0; i < N; i++) {
    cout << pairs[i].second + 1 << endl;
  }
  return 0;
}

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

#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }
/*
#include <bits/stdc++.h>
using namespace std;
 */
struct BIT {
	vector<int> v;
	int n;

	BIT() { init(); }
	BIT(int size) :n(size){ init(); }

	void init() {
		v.clear();
		v.resize(n + 1, 0);
	}

	int sum(int i, int idx = 1) {
//		idx--; idx *= -1; i += idx;
		int ret = 0;
		while (i) {
			ret += v[i];
			i -= i & -i;
		}
		return ret;
	}

	void add(int i, int x, int idx = 1) {
//		idx--; idx *= -1; i += idx;
		while (i <= n) {
			v[i] += x;
			i += i & -i;
		}
	}
};

int main() {
	int n = in(), q = in();
	BIT bit(n);

	rep(_, q) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		if (a)
			printf("%d\n", bit.sum(c) - bit.sum(b - 1));
		else 
			bit.add(b, c);
	}
}

Measured memory_bytes: 3468
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const ll mod = 1000000007;
const int MAX_N = 100010;

Graph to(MAX_N), cost(MAX_N);
vector<int> visit(MAX_N), d(MAX_N);

bool dfs(int v, int dist) {
 
    if(visit[v]) {

        if(d[v] != dist) {
            return false;
        }
        
        return true;
    }

    visit[v] = 1;
    d[v] = dist;
    rep(u, to[v].size()) {
        if( !dfs(to[v][u], d[v] + cost[v][u]) ) {
            return false;
        }
    }
 
    return true;
}

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

    rep(i, m) {
        int L, R, w;
        cin >> L >> R >> w;
        L--;  R--;
        to[L].push_back(R);
        to[R].push_back(L);
        cost[L].push_back(w);
        cost[R].push_back(-w);
    }

    rep(i, n) {
        if(!visit[i] && !dfs(i, 0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 15872
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::Ordering;

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

use std::cmp::{max, min};

fn main() {
    let n: usize = read();
    let m: i64 = read();
    let mut a: Vec<i64> = read_n(n);
    let search_max = 2 * a.iter().max().unwrap() + 1;

    a.sort();

    let criterion = |aa: i64| -> bool {
        let mut found = 0;
        for i in 0..n {
            let search = a.lower_bound(&(aa - a[i]));
            found += (a.len() - search) as i64;
        }
        found >= m
    };

    let (ok, ng) = binary_search(0, search_max, criterion);

    let aa = ok;
    let mut ans = 0;
    let mut found = 0;

    for i in 0..n {
        let search = a.lower_bound(&(aa - a[i]));
        ans += (a.len() - search) as i64 * a[i] * 2;
        found += (a.len() - search) as i64;
    }
    ans -= ok * (found - m);
 
    println!("{}", ans);

}


fn binary_search<F>(lb: i64, ub: i64, criterion: F) -> (i64, i64) where F: Fn(i64) -> bool {
    let mut ok = lb;
    let mut ng = ub;
    while ng - ok > 1 {
        let mid = (ng + ok) / 2;
        if criterion(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    (ok, ng)
}

Measured memory_bytes: 13692
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,m,c;
    cin >> n >> m >> c;
    vi a(m);
    rep(i,m)cin >> a[i];
    int ans = 0;
    rep(i,n){
        int t = 0;
        rep(j,m){
            int in;
            cin >> in;
            t += in*a[j];
        }
        if(t + c > 0)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>

using namespace std;

#define LLInt long long int

LLInt n, m;
int par[100001];
LLInt t_size[100001];

int find(int x) {
    if (par[x] == x) return x;
    par[x] = find(par[x]);
    return par[x];
}

void unite(int x, int y) {
    int rootx = find(x), rooty = find(y);
    par[rooty] = rootx;
    t_size[rootx] += t_size[rooty];
}

int main() {
    int a[100001], b[100001];
    cin >> n >> m;

    for (int i=0; i<m; i++) {
        scanf("%d %d", &a[i], &b[i]);
    }

    // init
    for (int i=0; i<=100000; i++) {
        par[i] = i;
        t_size[i] = 1;
    }

    LLInt ans[100000];
    ans[m-1] = n*(n-1)/2;
    for (int i=2; i<=m; i++) {
        int roota = find(a[m-i+1]), rootb = find(b[m-i+1]);
        
        ans[m-i] = ans[m-i+1];
        
        if (roota != rootb) {
            ans[m-i] -= t_size[roota] * t_size[rootb];
            unite(roota, rootb);
        }
    }

    for (int i=0; i<m; i++) {
        cout << ans[i] << endl;
    }


    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  int a[1000];
  int min, max;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    if (i == 0)
    {
      min = a[i];
      max = a[i];
    }
    else
    {
      if (max < a[i])
        max = a[i];
      if (min > a[i])
        min = a[i];
    }
  }
  int c[1000] = { 0 };
  int k = 0;
  for (int i = min; i <= max; i++, k++)
  {
    for (int j = 0; j < n; j++)
    {
      c[k] += (i - a[j]) * (i - a[j]);
    }
  }
  sort(c, c + k);
  cout << c[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
string s;
int main() {
  cin>>s;
  int i = 0;
  int n = s.size();
  int j = n-1;
  while(i < n && s[i] != 'A') i++;
  while(j >= 0 && s[j] != 'Z') j--;
  cout<<j-i+1<<endl;
  return 0;
}

Measured memory_bytes: 640
/*
ソートするためにswap関数を作る
*/
/*
#include<iostream>
using namespace std;

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a >= b){
		swap(&a, &b);
	}
	else if(b >= c){
		swap(&b, &c);
	}
	else if(a >= c){
		swap(&a, &c);
	}

	cout << a << " " << b << " " << c << endl;
	return 0;
}
*/

#include<iostream>
using namespace std;
 
int swap(int* a, int* b) {
  int tmp;
  tmp = *b;
  *b = *a;
  *a = tmp;
}
 
int main () {
  int a, b, c, tmp = 0;
  cin >> a >> b >> c;
  if (a >= b) {
    swap(&a, &b);
  }
  if (a >= c) {
    swap(&a, &c);
  }
  if (b >= c) {
    swap(&b, &c);
  }
   
  cout << a << " " << b << " " << c << "\n";
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
/* constexpr ll MOD = ll(1e9) + 7LL; */
/* constexpr ll MOD = 998244353LL; */
ll MOD = 200003LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < (int)v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    int n, q;
    cin >> n >> q;
    dsu d(n);
    REP(i, q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
}

int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}


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

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<int> color(8, 0);

    int free_cnt = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if(a >= 3200) ++free_cnt;
        int v = a / 400;
        ++color[v];
    }

    int type = 0;
    rep(i,8) {
        if(color[i] >= 1) ++type;
    }

    int min_ans = type;
    int max_ans = type + free_cnt;

    if(type == 0) min_ans = 1;

    cout << min_ans << " " << max_ans << endl;
    return 0;
}

Measured memory_bytes: 3624