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

using namespace std;

typedef long long LL;

const int mod = 1e9 + 7;

inline int qpow(int e, int x, int m) {
	int ret = 1;
	assert(x >= 0);
	while (x) {
		if (x & 1) ret = 1LL * ret * e % m;
		x >>= 1;
		e = 1LL * e * e % m;
	}
	return ret;
}

inline int gcd(int x, int y) {
	return y ? gcd(y, x % y) : x;
}

int fac[1005], inv[1005];

inline int C(int n, int m) {
	if (n < m || m < 0 || n < 0)
		return 0;
	return (LL)fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int n, m, k;

int tot;
int lst[1005], to[1005], nxt[1005];

inline void addedge(int x, int y) {
	nxt[tot] = lst[x];
	to[tot] = y;
	lst[x] = tot++;
}

int times, stktop;
int dfn[1005], low[1005], col[1005], stk[1005];

int blocks;
int cnte[1005], cntv[1005];

void tarjan(int u, int fa = -1) {
	dfn[u] = low[u] = times++;
	for (int i = lst[u]; i != -1; i = nxt[i]) {
		if (i == fa)
			continue;
		if (dfn[to[i]] == -1) {
			stk[stktop++] = i;
			tarjan(to[i], i ^ 1);
			low[u] = min(low[u], low[to[i]]);
			if (low[to[i]] >= dfn[u]) {
				do {
					int x = stk[--stktop];
					++cnte[blocks];
					if (col[to[x]] != blocks) {
						col[to[x]] = blocks;
						++cntv[blocks];
					}
					if (col[to[x ^ 1]] != blocks) {
						col[to[x ^ 1]] = blocks;
						++cntv[blocks];
					}
				} while (stk[stktop] != i);
				++blocks;
			}
		} else if (dfn[to[i]] < dfn[u]) {
			stk[stktop++] = i;
			low[u] = min(low[u], dfn[to[i]]);
		}
	}
}

int main() {
	memset(lst, -1, sizeof lst);
	memset(dfn, -1, sizeof dfn);
	memset(col, -1, sizeof col);
	fac[0] = inv[0] = 1;
	for (int i = 1; i < 1005; ++i) {
		fac[i] = 1LL * fac[i - 1] * i % mod;
		inv[i] = qpow(fac[i], mod - 2, mod);
	}
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y), --x, --y;
		addedge(x, y);
		addedge(y, x);
	}
	for (int i = 0; i < n; ++i)
		if (dfn[i] == -1)
			tarjan(i);
//	cerr << "blocks = " << blocks << "\n";
//	for (int i = 0; i < blocks; ++i)
//		cerr << cnte[i] << " " << cntv[i] << "\n";
	int ans = 1;
	for (int i = 0; i < blocks; ++i)
		if (cnte[i] == 1)
			ans = (LL)ans * k % mod;
		else if (cnte[i] == cntv[i]) {
			int sum = 0;
			for (int j = 1; j <= cnte[i]; ++j)
				(sum += qpow(k, gcd(j, cnte[i]), mod)) %= mod;
			ans = (LL)ans * sum % mod * qpow(cnte[i], mod - 2, mod) % mod;
		} else
			ans = (LL)ans * C(cnte[i] + k - 1, k - 1) % mod;
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect()
}

fn read_int_tuple() -> (i32, i32) {
    let v = read_vec();
    (v[0], v[1])
}

fn main() {
    let (N, D) = read_int_tuple();
    let N = N as usize;
    let mut coords = vec![vec![]; N];
    for i in 0..N {
        coords[i] = read_vec();
    }
    let mut ans = 0;
    for i in 0..N-1 {
        for j in i+1..N {
            let d = dist(&coords[i], &coords[j]);
            if d == (d as i32) as f64 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

fn dist(c1: &Vec<i32>, c2: &Vec<i32>) -> f64 {
    if c1.len() != c2.len() {
        panic!("Vectors need to have the same dimension");
    }
    let mut d = 0.0;
    for i in 0..c1.len() {
        d += (c1[i] - c2[i]).pow(2) as f64;
    }
    d.sqrt()
}


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

int main(){
    ll k,a,b;
    cin >> k >> a >> b;
    ll flag=0;
    for(ll i=0;i<1000;i++){
        if(a<=k*i&&b>=k*i){
            flag=1;
            break;
        }
    }
    if(flag==0)
    cout << "NG" << endl;
    else
    cout << "OK" << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	if (s[0]=='Y'&& s[1]=='A'&&s[2]=='K'&&s[3]=='I')
	{
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

int main(){
  int n;
  cin>>n;
  vector<int>a(9);
  int tmp;
  rep(i,n){
    cin>>tmp;
    if(tmp>=3200)a[8]++;
    else a[tmp/400]++;
  }
  int mi=0;
  int ma=0;
  int r=0;
  rep(i,8){
    if(a[i]!=0)mi++;
  }
  r=8-mi;
  ma=mi+a[8];

  mi=max(1,mi);
  cout<<mi<<" "<<ma<<endl;
    
    
  return 0;
}


Measured memory_bytes: 3556
n,m = map(int,input().split())
a = list(map(int,input().split()))
freeday = 0
needday = 0

for i in range(m):
    needday += a[i]
    if needday > n:
        freeday = -1
        break
else:
    freeday = n - needday

print(freeday)
    


Measured memory_bytes: 9968
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    
template<typename T>
T lcm(T a, T b){
    return a/gcd(a,b)*b;
}       

int main(){
    ll c=0,d=0,k=0,n,h,w,l,r,ans;
    string s,s1,s2;
    cin >> n;
    ans = 1LL;
    for(int i=0;i<n;i++){
        cin >> d;
        ans = lcm(ans,d);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
int n,m,dp[M];
bool vis[M];
vector<int> e[M];
int dfs(int cur) {
    if (vis[cur]) {
        return dp[cur];
    }

    int &res = dp[cur];
    for (int i:e[cur]) res = max(res, 1+dfs(i));
    vis[cur] = true;
    return res;
}
int main()
{
    scanf("%d %d", &n, &m);
    REP(i,1,m) {
        int x,y;
        scanf("%d %d", &x, &y);
        e[x].push_back(y);
    }

    int ans = 0;
    REP(i,1,n) ans = max(ans, dfs(i));
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 11740
/**
  @file a.cpp
  @title
  @url https://atcoder.jp/contests/abc157/tasks/abc157_a
**/

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

typedef long long LL;
typedef unsigned long long uLL;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SZ(x) ((int)(x).size())

#define REPI(i, a, b) for (LL i = LL(a); i < LL(b); ++i)
#define REP(i, N) for (LL i = LL(0); i < LL(N); ++i)
#define REPS(i, N) for (int i = 1; i <= (int)(N); i++)
#define RREP(i, N) for (int i = ((int)(N)-1); i >= 0; i--)
#define RREPS(i, N) for (int i = ((int)(N)); i > 0; i--)

#define chmax(ret, x) ret = max(ret, x)
#define chmin(ret, x) ret = min(ret, x)

#define FILL(x, e) memset(x, e, sizeof(x))
#define ZEROS(x) fill(x, 0)

#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(RALL(x))

#define UNIQ(x) x.erase(unique(ALL(x)), x.end());

#define BIT(n) (1LL << (n))

#define OUT(x) cout << (x) << "\n"
#define DEBUG(x) cerr << #x << " : " << x << "\n"
#define DEBUG2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second

const int MOD = 1e9 + 7;

void iostream_init() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(12);
  // cout.fill('0');
  // cout.width(3);
}

int main() {
  ::iostream_init();

  int N;
  cin >> N;

  OUT((N + 1) / 2);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

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

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int k;
		cin>>k;
		vector<vector<pair<int,int>>> v;
		int cnt=0;
		vector<pair<int,int>> z;
		z.push_back({1,-1});
		z.push_back({2,-1});
		z.push_back({3,-1});
		z.push_back({4,-1});
		z.push_back({5,-1});
		z.push_back({6,-1});
		z.push_back({7,-1});
		z.push_back({8,-1});
		z.push_back({9,-1});
		int i=0;
		string s;
		int o=-1;
		while(1){
			vector<pair<int,int>> ha;
			int j=0;
			for(int ko=0;ko<z.size();ko++){
				cnt++;
				if(cnt==k){
					s+=z[ko].first+'0';
					j=z[ko].second;
					i=v.size()-1;
					while(i>=0){
						s+=v[i][j].first+'0';
						j=v[i][j].second;
						i=i-1;
					}
					reverse(s.begin(),s.end());
					cout<<s;
					return 0;
				}
				int hl=z[ko].first;
				if(hl>=1&&hl<=8){
					ha.push_back({hl-1,ko});
					ha.push_back({hl,ko});
					ha.push_back({hl+1,ko});
				}
				else if(hl==0){
					ha.push_back({hl,ko});
					ha.push_back({hl+1,ko});
				}
				else{
					ha.push_back({hl-1,ko});
					ha.push_back({hl,ko});
				}
			}
			v.push_back(z);
			z=ha;
		}
	}
	return 0;
}

Measured memory_bytes: 3936
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func allAtoi(num []string) []int {
	conv := make([]int, len(num))
	for i, item := range num {
		conv[i], _ = strconv.Atoi(item)
	}
	return conv
}

func main() {
	nk := allAtoi(strings.Split(nextLine(), " "))
	ans := nk[0] - nk[1] + 1
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef vector<vector<ll>> matrix;

vector<int> gains[100000];
int numSkipped[100000];
void solve() {
	int n, k;
	cin >> n >> k;
	ll ret = 0;
	for(int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		gains[--a].push_back(b);
		ret += b;
	}
	for(int i = 0; i < n; i++) if(gains[i].size()) sort(gains[i].begin(), gains[i].end());
	priority_queue<pii> multi;
	priority_queue<pii> single;
	ll bonus = 0;
	for(int i = 0; i < n; i++) {
		if(gains[i].size() == 0) continue;
		bonus++;
		if(gains[i].size() == 1) {
			single.push({-gains[i][0], i});
		}
		else {
			multi.push({-gains[i][0], i});
		}
	}
	while(n-- > k) {
		if(multi.empty()) {
			bonus--;
			ret += single.top().first;
			single.pop();
		}
		else if(single.empty()) {
			pii curr = multi.top(); multi.pop();
			ret += curr.first;
			if(++numSkipped[curr.second] == gains[curr.second].size()-1) {
				single.push({-gains[curr.second][numSkipped[curr.second]], curr.second});
			}
			else {
				multi.push({-gains[curr.second][numSkipped[curr.second]], curr.second});
			}
		}
		else {
			ll multiLoss = -multi.top().first;
			ll singleLoss = -single.top().first + 2 * bonus - 1;
			if(multiLoss <= singleLoss) {
				pii curr = multi.top(); multi.pop();
				ret += curr.first;
				if(++numSkipped[curr.second] == gains[curr.second].size()-1) {
					single.push({-gains[curr.second][numSkipped[curr.second]], curr.second});
				}
				else {
					multi.push({-gains[curr.second][numSkipped[curr.second]], curr.second});
				}
			}
			else {
				bonus--;
				ret += single.top().first;
				single.pop();
			}
		}
	}
	cout << ret + bonus*bonus << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
	/*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
	*/
	solve();
}


Measured memory_bytes: 6904
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

const int N = int(5e3) + 2;

bitset<N> f;
int n, k, a[N], sum[N], first;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> k;
    for(int i = 1; i <= n; ++i) cin >> a[i], a[i] = min(a[i], k);
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + a[i];
    f.set(0);
    for(int i = n; i >= 1; --i) {
       bool check = 0;
       for(int j = k - 1; j >= 0; --j)
           if(f.test(j)) {
              if(j + sum[i] < k) check = 1;
              break;
           }
       f = f | (f << a[i]);
       if(check) return cout << i, 0;
    }
    cout << 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

struct UnionFind{
  vector<int> par;

  UnionFind(int N) : par(N){
    for(int i=0;i<N;i++) par[i] = i;
  }

  void init(int N){
    for(int i=0;i<N;i++) par[i] = i;
  }

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

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
  }

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

int main(){
  int N,M; cin >> N >> M;
  int p[100005];
  // UnionFind x(N);
  UnionFind px(N+1);
  for(int i=1;i<=N;i++) cin >> p[i];

  for(int i=1;i<=M;i++){
    int a,b; cin >> a >> b;
    // x.unite(a,b);
    px.unite(p[a],p[b]);
  }

  int ans = 0;
  for(int i=1;i<=N;i++){
    if(px.same(i,p[i])) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define SZ(x) x.size()
#define POP __builtin_popcount
#define CLZ __builtin_clz
#define CTZ __builtin_ctx
constexpr int INF {INT_MAX};
constexpr float INFF {FLT_MAX};
constexpr long long INFL {LLONG_MAX};
#define float long double
#define int long long

main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.setf(ios::fixed);
	int a,b;
	cin>>a>>b;
	if (b>=a) cout <<"unsafe\n";
	else cout << "safe\n";
	
}


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


int main()
{
	string s;

	cin>>s;

	ll n=s.size();
	cout<<s;

	if(s[n-1]=='s') cout<<"es"<<endl;
	else cout<<"s"<<endl;



	return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fst first
#define snd second
using ll = long long;
using I = pair<int, int>;

int main() {
  int a, b;
  while (cin >> a >> b) {
    int d = b - a;
    int k = d - 1;
    int res = k * (k + 1) / 2 - a;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var count = Console.ReadLine().Split(' ').Distinct().Count();
            Console.WriteLine(count == 3 ? "Three" : "Four");
        }
    }
}

Measured memory_bytes: 13276
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

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

#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
#define deb(x) cout<<#x<<" "<<x<<"\n"
#define Clear(x) memset(x,0,sizeof(x))
#define all(x) (x).begin(),(x).end()

void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pair< ll,ll > &a,pair< ll,ll > &b)
{
	if(a.ff!=b.ff)
		return a.ff<b.ff;
	else
	{
		if(a.ss>b.ss)
			return b.ss<a.ss;
		else if(a.ss<b.ss)
			return a.ss<b.ss;
	}
	return a.ff>b.ff;
}

ll powe(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}

int main()
{
	checkpoint1();
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans=-inf;
	if(a<=0&&b>=0 || c<=0&&d>=0)
		ans=0;
	ans=max(ans,max(a*c,b*d));
	ans=max(ans,max(a*d,b*c));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int w,h,n;
  cin>>w>>h>>n;
  vector<vector<int>> a(n, vector<int>(3));
    for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a.at(i).at(j);
    }
  }
  int x=0;
  int b=w;
  int c=0;
  int d=h;
  for(int i=0;i<n;++i){
    if(a.at(i).at(2)==1){
      x=max(a.at(i).at(0),x);
    }
    if(a.at(i).at(2)==2){
      b=min(a.at(i).at(0),b);
    }
    if(a.at(i).at(2)==3){
      c=max(a.at(i).at(1),c);
    }
    if(a.at(i).at(2)==4){
      d=min(a.at(i).at(1),d);
    }
  }
  if (x>b) cout<<0;
  else if(c>d) cout<<0;
  else cout<<(x-b)*(c-d);
  }

Measured memory_bytes: 256
n, m = map(int, input().split())

s = []
c = []
num = []

for i in range(m):
    si, ci = map(int, input().split())
    s.append(si)
    c.append(ci)

if len(c) is 0:
    if n is 1:
        print(0)
        exit()
    elif n is 2:
        print(10)
        exit()
    else:
        print(100)
        exit()
        

for j in range(n):
    num.append(-1)

for k in range(len(s)):
    if s[k] is 1 and c[k] is 0 and n is not 1:
        print(-1)
        exit()
    if num[s[k]-1] is not -1 and num[s[k]-1] is not c[k]:
        print(-1)
        exit()
    else:
        num[s[k]-1] = c[k]

is_filled = False
for l in range(n):
    if num[l] is -1:
        if not is_filled:
            num[l] = 1
            is_filled = True
        else:
            num[l] = 0
    else:
        is_filled = True

print(''.join([str(x) for x in num]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  int ans=0;
  cin>>n>>k;
  map<int, int> cnt;
  
  for(int i=0;i<k;i++){
    int a;
    cin>>a;
    vector<int>vec(a);
     for(int j=0;j<a;j++){
        cin>>vec.at(j);
      }
       for (int x : vec) {
         if (cnt.count(x)) {
      // 既に含まれているならインクリメント
          cnt.at(x)++;
        } else {
      // 含まれていないなら、1を追加
          cnt[x] = 1;
    }
  }
  }
     for(int i=1;i<n+1;i++){
       if(!cnt.count(i)){
         ans++;
       }
     }
          cout<<ans<<endl;
}
  

      

Measured memory_bytes: 3632
/*
           Nothing is absolute.
     This is the only absolute truth.
*/

#include<bits/stdc++.h>

using namespace std;

using ull = unsigned long long;
using ll = long long;

#define READ freopen("input.txt", "r", stdin)
#define ROUT freopen("output.txt", "w", stdout)
#define pb push_back
#define endl '\n'

///**** Warning : 18++ Material!!! ****///

void fasterIO()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void fileIO()
{
    READ;
    ROUT;
}

///(Moan) ey (hoe) pakhi jeno (Oral) dibe <3

void codehub()
{
    int n, a, b;
    cin>>n>>a>>b;
    if(n*a<b)
        cout<<n*a<<endl;
    else
        cout<<b<<endl;
}

///***Don't Send Nudes. Send Codes***///

int main()

{
    ///fileIO();
    fasterIO();

    codehub();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<ll> up(n + 1), down(n + 1);
    rep(i, n) {
        if (s[i] == '<') up[i + 1] = up[i] + 1;
    }
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '>') down[i] = down[i + 1] + 1;
    }

    ll ans = 0;
    rep(i, n + 1) {
        ans += max(up[i], down[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 11688
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, t;
  cin >> n >> t;
  vector<ll> a(n);
  ll ans = 0;
  ll mx = 0;
  ll mn = INF;
  REP(i, n){
    cin >> a[i];
    if(mn > a[i]){
      mn = a[i];
      continue;
    }
    ll d = a[i] - mn;
    if(d == mx) ans++;
    if(d > mx){
      mx = d;
      ans = 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<int> a(n);
	rep(i,n){
		cin>>a[i];
	}
	vector<Pi> b(m);
	rep(i,m){
		cin>>b[i].se>>b[i].fi;
	}
	sort(begin(b),end(b),greater<Pi>());
	bool flag=false;
	rep(i,m){
		rep(j,b[i].se){
			if(a.size()!=2*n){
				a.push_back(b[i].fi);
			}else{
				flag=true;
				break;
			}
		}
		if(flag) break;
	}
	sort(begin(a),end(a),greater<int>());
	ll ans=0;
	rep(i,n){
		ans+=a[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int ans,a,b,c,x,y;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a>>b>>c>>x>>y;
    ans = a*x + b*y;
    if(2*c<a+b){
        for(int i=1;i<=min(x,y);i++){
            ans += 2*c;
            ans -= a+b;
        }
    }
    if(y>x && 2*c<b){
        for(int i=1;i<=y-x;i++){
            ans -=b;
            ans +=2*c;
        }
    }
    else if(x>y && 2*c<a){
        for(int i=1;i<=x-y;i++){
            ans -=a;
            ans +=2*c;
        }
    }

    cout<<ans<<newl;
}


Measured memory_bytes: 256
N = int(input())
S = input()
e_count = S.count('E')
w_count = 0
ans = e_count
for s in S:
    if s == 'E':
        e_count -= 1
    else:
        w_count += 1
    ans = min(ans, e_count + w_count)
print(ans)

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
ll x,y,i=0; 
int main()
{
	ios::sync_with_stdio(false);
	cin>>x>>y;
	for (i;x<=y;++i){
		x*=2;
	}
	cout<<i;
	return 0;
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)


func nextInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func enunique(ints []int) []int {
	u := make([]int, 0, len(ints))
	m := make(map[int]bool)
	for _, val := range ints {
		if _, ok := m[val]; !ok {
			m[val] = true
			u = append(u, val)
		}
	}
	return u
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := range a {
		a[i] = nextInt()
	}
	a = enunique(a)
	for i := range a {
		if i == len(a)-1 {
			fmt.Println(a[i])
		} else {
			fmt.Printf("%d ", a[i])
		}
	}
}


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

int main(){
  int n, a, zero = 0, ans = 1;
  int cnt[100010] = {};
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    if(a == 0){
      zero++;
      cnt[a+1]++;
      cnt[a]++;
    }else{
      cnt[a+1]++;
      cnt[a-1]++;
      cnt[a]++;
    }
  }
  for(int i = 0; i < 100010; i++){
    if(ans < cnt[i]) ans = cnt[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	while(1){
		int n,a,b,c,x,y,sum=0;
		cin >> n >> a >> b >> c >> x;
		if(!n&&!a&&!b&&!c&&!x)	break;
		for(int i=0;i<n;i++){
			cin >> y;
			while(1){
				if(x==y){
					if(i==n-1)	break;
					x = (a*x+b)%c;
					sum++;
					break;
				}
				x = (a*x+b)%c;
				sum++;
				if(sum>10000)	break;
			}
		}
		if(sum>10000)	cout << -1 << endl;
		else	cout << sum << endl;
	}
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
int main(void) {
    int a, b; cin >> a >> b;
    char ans;
    if(a+b==15) ans = '+';
    else if(a*b==15) ans = '*';
    else ans = 'x';
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,x,y,k=0;
    cin>>n>>x>>y;
    map<int,int>jp;
    for(int i=1;i<n;i++)
    {
        jp[i]=0;
    }
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {   
            int a,b;
            a=abs(y-i)+1+abs(x-j);
            b=abs(y-j)+1+abs(x-i);
            int mini=min({j-i,a,b});
            jp[mini]++;
        }
    }
    for(auto it=jp.begin();it!=jp.end();it++)
    {
        cout<<it->second<<"\n";   
    }
     
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n){
        int in;
        cin >> in;
        p.at(i) = in;
    }
    int min = INT_MAX;
    int cnt = 0;
    rep(i,n){
        if(min > p.at(i)){
            min = p.at(i);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n, w, z;
  cin >> n >> z >> w;
  vi a(n);
  REP(i, n) { cin >> a[i]; }

  if (n == 1) {
    cout << abs(a[0] - w) << endl;
  } else {
    cout << max(abs(a[n - 2] - a[n - 1]), abs(w - a[n - 1])) << endl;
  }
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
struct INF { template<class T> operator T() { return numeric_limits<T>::max() / 2; } } INF;


int main(){

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = INF;
    ans *= -1;
    chmax(ans, a*c);
    chmax(ans, a*d);
    chmax(ans, b*c);
    chmax(ans, b*d);

    cout << ans << endl;
}

Measured memory_bytes: 3628
(K, ) = [int(n) for n in input().split()]

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

res = 7 % K
ans = 1
while res != 0:
    res *= 10
    res += 7
    res %= K
    ans += 1
    
print(ans)


Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull type1(ull h,ull w){
	ull s[3],res=1e9,i;
	if(h<3) return w;
	else{
		for(i=1;i<=h-2;i++){
			s[0]=i*w;
			s[1]=(h-i)/2*w;
			s[2]=((h-i)-(h-i)/2)*w;
			sort(s,s+3);
			res=min(s[2]-s[0],res);
		}
		return res;
	}
}
ull type2(ull h,ull w){
	ull s[3],res=1e9,i;
	for(i=1;i<=h-1;i++){
		s[0]=i*w;
		s[1]=(h-i)*(w/2);
		s[2]=((h-i)*w)-((h-i)*(w/2));
		sort(s,s+3);
		res=min(s[2]-s[0],res);
	}
	return res;
}
int main(){
	ull ans,h,w;
	cin>>h>>w;
	ans=min(type1(h,w),type1(w,h));
	ans=min(type2(h,w),ans);
	ans=min(type2(w,h),ans);
	cout<<ans;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int t = N, c = 0;
  while (t > 0)
    c += t % 10, t /= 10;
  if (N % c == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
	long double a,b,x,temp;
	cin >> a >> b >> x;
	if(x >= (a*a*b)/2)
	{
		temp=(2*((a*a*b)-x))/(a*a*a);
//		temp=temp*(180);
//		temp=temp/(3.1415);
		cout << setprecision(12) << atan(temp)*(180/3.141592653589793238462643383279502884) << endl;
	}
	else
	{
		temp=(a*b*b)/(2*x);
//		temp=temp*(180);
//		temp=temp/(3.1415);
		cout << setprecision(12) << atan(temp)*(180/3.141592653589793238462643383279502884) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#define N 200005
using namespace std;
char str[N],mm[N];
int dp[N];
int route[N];
int a[30];
int main(void)
{
    scanf("%s",str + 1);
    int l = strlen(str+1);
    //memset(nex,-1,sizeof(nex));
    memset(route,-1,sizeof(route));
    memset(dp,0x3f,sizeof(dp));
    memset(a,-1,sizeof(a));
    int id = 0;
    dp[l+1] = 1;
    route[l+1] = l + 1;
    mm[l+1] = 0;
    for(int i = l+2;i < N;i++)
        dp[i] = 0;
    for(int i = 0; i < 26; i++)
        a[i] = l+1;
    for(int i = l; i >= 1; i--)
    {
        a[str[i]-'a'] = i;
        for(int j = 0; j < 26; j++)
        {
            if(dp[i] > dp[a[j] + 1] + 1)
            {
                mm[i] = j;
                //printf("%d\n",j);
                dp[i] = dp[a[j] + 1]+1;
                route[i] = a[j] + 1;
            }
        }
    }
    //printf("%d\n",dp[1]);
    int f = 1;
    while(f<l+1)
    {
        printf("%c",mm[f] + 'a');
        f = route[f];
    }
    return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <string.h>

int get_int() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return -1;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}
int get_str(char *str) {
    int c = getchar_unlocked();
    if(c == -1) return -1;
    while(c > 32) {
        *str++ = (char)c;
        c = getchar_unlocked();
    }
    *str = 0;
    return 0;
}

// prime number
#define M 49762109
char dic[M][13];

// base: 5
int str_key(char *str){
    int key = 0;
    for(int i = 1; *str; i*=5) {
        switch(*str++) {
            case 'A': key += 1 * i;
                      break;
            case 'C': key += 2 * i;
                      break;
            case 'G': key += 3 * i;                                                               break;
            case 'T': key += 4 * i;
                      break;
            defaut:   break;
        }
    }
    return key;
}
#define hash_key(k) ((k) % M)
#define hash_alt(k) (1 + ((k) % (M - 1)))
#define hash(k, i) ((hash_key(k) + (i) * hash_alt(k)) % M)
int dic_find(char *str){
    int key = str_key(str);
    size_t len = strlen(str);
    int hash;
    for(int i = 0;; ++i) {
        hash = hash(key, i);
        // found
        if(strlen(dic[hash]) == len && strncmp(dic[hash], str, len) == 0) return 1;
        // not exist
        if(strlen(dic[hash]) == 0) return 0;
        // else: found other key
    }
}
void dic_insert(char *str){
    int key = str_key(str);
    size_t len = strlen(str);
    int hash;
    for(int i = 0;; ++i) {
        hash = hash(key, i);
        // already exist
        if(strlen(dic[hash]) == len && strncmp(dic[hash], str, len) == 0) return;
        // insert
        if(strlen(dic[hash]) == 0){
            strcpy(dic[hash], str);
            return;
        }
        // else: hash used by other key
    }
}

int main(int argc, char **argv) {
    int n = get_int();
    char c[13];
    for(int i = 0; i < n; ++i) {
        get_str(c);
        if(*c == 'i') {
            get_str(c);
            dic_insert(c);
        } else {
            get_str(c);
            if(dic_find(c)) puts("yes");
            else puts("no");
        }
    }
    return 0;
}



Measured memory_bytes: 47396
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio>
 
#define nl '\n'
 
using namespace std;
 
int n, m, s, c, a, x;

int num[4];

bool checkValid(int i){
    string str = to_string(i);
    int t[n];
    for(int i = 0; i < n; i++){
        t[i] = str[i] - '0';
    }
    for(int i = 0; i < str.size(); i++){
        if(num[i] != -1 && num[i] != t[i]){
            return false;
        }
    }
    return true;
}

int main(){

    cin >> n >> m;

    vector<set<int> > arr;

    for(int i = 0; i < n; i++){
        arr.push_back({});
    }

    for(int i = 0; i < n; i++){
        num[i] = -1;
    }

    vector<pair<int, int > > v;

    for(int i = 0; i < m; i++){
        cin >> s >> c;
        arr[s-1].insert(c);
        v.push_back(make_pair(s, c));
    }

    for(int i = 0; i < n; i++){
        if(arr[i].size() > 1){
            cout << -1;
            return 0;
        }
    }

    for(int i = 0; i < v.size(); i++){
        num[(v[i].first)-1] = v[i].second;
    }

    if(n == 1){
        a = 0;
        x = 9;
    } else if(n == 2){
        a = 10;
        x = 99;
    } else if(n == 3){
        a = 100;
        x = 999;
    }

    for(int i = a; i < x+1; i++){
        if(checkValid(i)){
            cout << i;
            return 0;
        }
    }

    cout << -1;

    return 0;





}
 
//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out
 
//Surely this will AC

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);
    for (int i =0;i<N;i++)
    {
        cin >> x[i] >> y[i] >> h[i];
    }

    int MAX=100;

    for(int posY=0; posY <=MAX; posY++)
    {
        for(int posX =0; posX<=MAX; posX++)
        {
            int needH=-1;
            for (int i =0; i<N; i++)
            {
                if(h[i]>0){
                    int tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i]);
                    if (needH == -1){
                        needH = tmp;
                    }
                    else{
                        if (needH != tmp){
                            needH = -2;
                            break;

                        }
                    }
                }
            }

            for (int i=0;i<N;i++)
            {
                if (h[i]==0)
                {
                    int dist = abs(posY - y[i]) + abs(posX -x[i]);
                    if (needH > dist){
                        needH = -2;
                        break;
                    }
                }
            }
            if (needH == -2) continue;

            cout << posX << " " << posY << " " << needH << " " << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <map>
#include <bitset>
#include <string.h>
#include <cmath>
#include <queue>
#include <algorithm>
#define N 10005
#define P pair<int,int>
#define ll long long
#define mk(a, b) make_pair(a, b)
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
int inf = 0x3f3f3f3f;
int  n, m;
struct ac{
	int e, l, c;
	bool operator < (const ac &x) const{
		return x.l < l;
	}
};
vector<ac> g[N];
bool vis[N];
int dis[N], mon[N];
void Dijkstra() {
	mem(dis, inf);
	mem(mon, inf);
	mem(vis, false);
	dis[1] = 0;
	mon[1] = 0;
	priority_queue<ac, vector<ac> >que;
	que.push((ac){1, 0, 0});
	while (!que.empty()) {
		ac first = que.top();
		que.pop();
		int e = first.e;
		int l = first.l;
		int c = first.c;
		if (vis[e])	continue;
		// if (dis[e] < l || vis[e] || mon[e] < c)	continue;
		vis[e] = true;
		for (int j = 0; j < g[e].size(); ++j) {
			ac t = g[e][j];
			if (vis[t.e])	continue;
			if (l + t.l < dis[t.e]) {
				dis[t.e] = l + t.l;
				mon[t.e] = t.c;
				que.push((ac){t.e, dis[t.e], mon[t.e]});
			}else if (l + t.l == dis[t.e]) {
				mon[t.e] = min(mon[t.e], t.c);
			}
		}
	}

}
int main(){
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
// #endif
	ios::sync_with_stdio(false);
	while (cin >> n >> m, n + m) {
		for (int i = 0; i < m; ++i) {
			int s, e, l, c;
			cin >> s >> e >> l >> c;
			g[s].push_back((ac){e, l, c});
			g[e].push_back((ac){s, l, c});
		}

		Dijkstra();
		int ans = 0;
		for (int i = 1; i <= n; ++i) {
			ans += mon[i];
			// cout << mon[i] << " ";
		}
		cout << ans << endl;
		for (int i = 1; i <= n; ++i) {
				g[i].clear();
		}
	}

	return 0;
}



Measured memory_bytes: 5164
import sys
from functools import reduce
def rerooting(N, adj, merge, finalize,identity):
    """
    merge: (T,T) -> T
    This merges two dp results. (T, operator) must be a monoid.

    identity: operator(x, identity) = operator(identity, x) = x
    
    finalize: T -> T
    This transforms the merged result to the dp result
    """

    order = [None]*N
    parent = [None]*N
    parent[0] = -1
    stack = [0]
    for i in range(N):
        v = stack.pop()
        order[i] = v
        for u in adj[v]:
            if parent[u] is None:
                parent[u] = v
                stack.append(u)

    # from leaf to parent
    dp_down = [None]*N
    for v in reversed(order[1:]):
        p = parent[v]
        dp_down[v] = finalize(reduce(merge,
            (dp_down[c] for c in adj[v] if c != p),
            identity))

    # from parent to leaf
    dp_up = [None]*N
    dp_up[0] = identity
    for v in order:
        if len(adj[v]) == 1 and adj[v][0] == parent[v]:
            continue
        p = parent[v]
        left = [dp_up[v]]
        for u in adj[v]:
            if u != p:
                left.append(merge(left[-1],dp_down[u]))

        right = [identity]
        for u in reversed(adj[v]):
            if u != p:
                right.append(merge(dp_down[u],right[-1]))
        i = 0
        for u in adj[v]:
            if u != p:
                dp_up[u] = finalize(merge(left[i],right[-i-2]))
                i += 1

    for v,l in enumerate(adj):
        order[v] = reduce(merge,
                    (dp_down[u] for u in adj[v] if u != parent[v]),
                    identity)
        order[v] = finalize(merge(order[v], dp_up[v]))

    return order


def solve(N,edges):
    MOD = 10**9+7

    factorio = [1]*(N+1)
    t = 1
    for i in range(1,N+1):
        t *= i
        t %= MOD
        factorio[i] = t

    adj = [[] for _ in range(N)]
    for a,b in edges:
        adj[a].append(b)
        adj[b].append(a)

    def func(x,y):
        cx,nx = x
        cy,ny = y
        c = cx*cy*factorio[nx+ny]*pow(factorio[nx]*factorio[ny],MOD-2,MOD)
        c %= MOD
        n = nx+ny
        return c, n

    def func2(x):
        c,n = x
        return c,n+1

    identity = (1,0)

    res = rerooting(N, adj, func, func2, identity)

    for k,n in res:
        print(k)


if __name__ == '__main__':
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
     
    N = int(readline())
    m = map(int, read().split())
    edges = tuple((a-1,b-1) for a,b in zip(m, m))

    solve(N, edges)


Measured memory_bytes: 239264
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005

using namespace std;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {


       ll N;
       cin>>N;
       unordered_map<string,bool> mp;
       forn(i,N){
        string s;
        cin>>s;
        mp[s]=1;;
       }
       cout<<mp.size()<<endl;







    }



    return 0;
}


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

int main(){
  char N[3];
  cin >> N;
  if(N[0] == N[1] && N[1] == N[2])
    cout << "Yes\n";
  else if(N[1] == N[2] && N[2] == N[3])
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
    int i;
    // Your code here!
    int n;
    cin >> n;
    ll ans=1;
    for(i=1;i<=n;i++){
        ans = (ans * i) % MOD;
    }
    cout << ans << endl;
}


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

int main() {
  
  string S;
  cin >> S;
  
  int counter = 700;
  
  if (S.at(0) == 'o') counter = counter + 100;
  if (S.at(1) == 'o') counter = counter + 100;
  if (S.at(2) == 'o') counter = counter + 100;
    cout << counter << endl;

}

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

int n;

const int NIL = -1;
struct Node {
  int parent, left, right;
};
vector<Node> T;

int getDepth(int u) {
  int d = 0;
  while (T[u].parent != NIL) {
    u = T[u].parent;
    ++d;
  }
  return d;
}

void printChildren(int u) {
  int c = T[u].left;
  int times = 0;
  while (c != NIL) {
    if (times != 0) cout << ", ";
    cout << c;
    c = T[c].right;
    ++times;
  }
}

string getType(int u) {
  if (T[u].parent == NIL) return "root";
  else if (T[u].left != NIL) return "internal node";
  else return "leaf";
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  T.reserve(n);
  for (int i = 0; i < n; ++i) {
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }
  for (int i = 0; i < n; ++i) {
    int id;
    cin >> id;
    int k;
    cin >> k;
    int prev_child;
    for (int j = 0; j < k; ++j) {
      int child;
      cin >> child;
      if (j == 0) T[id].left = child;
      T[child].parent = id;
      if (j != 0) T[prev_child].right = child;
      prev_child = child;
    }
  }

  for (int i = 0; i < n; ++i) {
    cout << "node " << i << ": parent = " << T[i].parent << ", depth = " << getDepth(i) << ", "
    << getType(i) << ", [";
    printChildren(i);
    cout << "]" << endl;
  }
}



Measured memory_bytes: 4096
n,m=map(int,input().split())

import sys
sys.setrecursionlimit(10**9) #再帰の上限をあげる

root=[-1 for i in range(n+1)] #自分が親ならグループの人数のマイナス倍を、そうでないなら（元）親の番号を示す

def r(x):   #親は誰？
    if root[x]<0:
        return x
    else:
        root[x]=r(root[x])
        return root[x]

def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    if root[x]>root[y]:
        x,y=y,x
    root[x]+=root[y]
    root[y]=x

for i in range(m):
    x,y,z=map(int,input().split())
    unite(x,y)


g=[0]*(n+1)
for i in range(1,n+1):
    g[r(i)]+=1
ans=0
for i in range(n+1):
    if g[i]>0:
        ans+=1
print(ans)



Measured memory_bytes: 80476