akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func split1(h, w int) int {
	if w < 3 {
		return h * w
	}
	a := w / 3
	b := (w - a) / 2
	c := w - a - b
	return (c - a) * h
}

func split2(h, w int) int {
	a := h / 2
	b := h - a
	m := h * w
	for i := 1; i < w; i++ {
		c := []int{i * h, (w - i) * a, (w - i) * b}
		sort.Ints(c)
		if c[2]-c[0] < m {
			m = c[2] - c[0]
		}
	}
	return m
}

func (con *contest) main() error {
	var h, w int
	con.Scan(&h, &w)
	a := split1(h, w)
	b := split1(w, h)
	if b < a {
		a = b
	}
	b = split2(h, w)
	if b < a {
		a = b
	}
	b = split2(w, h)
	if b < a {
		a = b
	}
	con.Println(a)
	return nil
}


Measured memory_bytes: 5504
import itertools

n = int(input())
s = [input() for _ in range(n)]
march = list("MARCH")
marchlist = [0 for _ in range(5)]

for i in range(n):
	for j in range(5):
		if s[i][0] == march[j]:
			marchlist[j] += 1

ans = 0
for i in itertools.combinations(marchlist, 3):
	tmpans = 1
	for j in range(3):
		tmpans *= i[j]
	ans += tmpans

print(ans)

Measured memory_bytes: 55256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n;
    cin >>  n;
    string s;
    cin >> s;
    for(int i=0; i<s.size(); i++){
        char t;
        t = (s[i] + n - 'A')%26 + 'A';
        cout << t;
    }
    cout << endl;
    return 0;
}


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

// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
	  // 最初は全てのデータiがグループiに存在するものとして初期化
	  for(int i = 0; i < n; i++){
		  par[i] = i;
	  }
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

long long N, M;

int main(){
	cin >> N >> M;
	UnionFind uf = UnionFind(N);
	for(long long i = 0; i < M; i++){
		long long x, y, z;
		cin >> x >> y >> z; x--;y--;
		uf.unite(x, y);
	}

	set<long long> group;
	for(long long i = 0; i < N; i++){
		group.insert(uf.find(i));
	}
	cout << group.size() << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define ms(x, v) memset(x, v, sizeof(x))
using namespace std;
const int N = 205, MOD = 998244353;
pair<int, int> s[N];
int operator ^ (pair<int, int> a, pair<int, int> b)
{
	return a.first * b.second - a.second * b.first;
}
pair<int, int> operator - (pair<int, int> a, pair<int, int> b)
{
	return make_pair(a.first - b.first, a.second - b.second);
}
void add(int &a, int b) { a = (a + b) % MOD; }
int pw[N];
int main()
{
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n;
	rep1(i, n) cin >> s[i].first >> s[i].second;
	pw[0] = 1;
	rep1(i, n) pw[i] = pw[i - 1] * 2 % MOD;
	int ans = pw[n];
	add(ans, MOD - 1);
	add(ans, MOD - n);
	rep1(i, n)
	{
		rep1(j, n)
		{
			if (s[i] < s[j])
			{
				int cnt = 0;
				rep1(k, n)
				{
					if (s[i] < s[k] && s[j] < s[k] && ((s[i] - s[k]) ^ (s[j] - s[k])) == 0) cnt++;
				}
				add(ans, MOD - pw[cnt]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>vec[200009];
int n,m;

int dfs(int now,int cnt){
  int rec=0;
  if(now==n)return 1;
  if(cnt==2)return 0;
  for(int i=0;i<vec[now].size();i++){
    rec+=dfs(vec[now][i],cnt+1);
  }
  return rec;
}

int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  if(dfs(1,0))cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return(0);
}


Measured memory_bytes: 12016
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        S: chars,
    }
    let m: HashSet<char> = S.into_iter().collect();
    if m.len() == 1 {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    double r, l, s;
    cin >> r;
    l = 2 * M_PI * r;
    s = r * r * M_PI;
    cout << fixed << setprecision(6) << s << " " << l << endl;
    return 0;
}


Measured memory_bytes: 3256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    ll a, b;
    cin >> a >> b;
    if ( abs(a+b) % 2 == 1 ) {
        cout << "IMPOSSIBLE" << endl;
    }
    else {
        cout << abs(a+b) / 2LL << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
L = []
for i in range(M):
    l = list(map(int,input().split()))+[i]
    L.append(l)
cnt = 0
tmp = []
M = sorted(L,key = lambda x: (x[0],x[1]))
for x in M:
    if tmp == x[0]:
        x.append(cnt+1)
        cnt += 1
    else:
        tmp = x[0]
        cnt = 0
        x.append(cnt)
M = sorted(L,key = lambda x:x[2])
#print(M)
for x in M:
    st = str(x[0]).zfill(6)
    st += str(x[3]+1).zfill(6)
    print(st)


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int x;cin >>x;
    int k;
    int g=__gcd(360,x);
     k=360*x/g;
     k/=x;
     cout <<k<<endl;
    return 0;
}


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

using namespace std;
using ll=long long;

int main()
{
    int n;cin >>n;
    int k=n;
    int s=0;
    while(k>0){
        s+=k%10;
        k/=10;
    }
    bool flg=true;
    if(n%s!=0)flg=false;
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main() {


	int N;
	int x, y;

	int t, xx, yy;
	int lastt = 0, lastxx = 0, lastyy = 0;
	int nextt, nextxx, nextyy;
	cin >> N;
	REP(i, N) {

		cin >> t >> xx >> yy;
		nextt = t - lastt;
		nextxx = xx - lastxx;
		nextyy = yy - lastyy;

		//cerr << "next:" << nextt << " " << nextxx << " " << nextyy << endl;

		if (nextt < abs(nextxx) + abs(nextyy)) { cout << "No" << endl; return 0; }
		//間に合うけど時刻道理ではない
		//到着したときに余った時間
		int t2 = nextt - abs(nextxx) - abs(nextyy);
		//cerr << "t2:" << t2 << endl;
		if(t2%2==1){ cout << "No" << endl; return 0; }

		lastt = t;
		lastxx = xx;
		lastyy = yy;
	}


	cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    int N;
    int ans=0;
    cin >> N;
    vector<int> L(N);
    for(int i=0;i<N;i++){
        cin >> L[i];
    }
    for(int i=0;i<N;i++){
        for(int j=i;j<N;j++){
            for(int k=j;k<N;k++){
                if(L[i]!=L[j]&&L[i]!=L[k]&&L[k]!=L[j]){
                    if(abs(L[i]-L[j])<L[k]&&L[k]<L[i]+L[j]) ans++;
                }
            }
        }
    }
    cout << ans <<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

int n, m, t, a[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  cin >> n;
  map<int, int> mp;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++mp[x], ++mp[x + 1], ++mp[x - 1];
  }
  for (auto x : mp) ans = max(ans, x.S);
  cout << ans;
  return 0;
}



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


const int MAX_V = 100;
const int INF = 1e9;

struct edge {
    int to, cap, rev;
};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size() - 1});
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    for (;;) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

int main() {
    int V, E;
    cin >> V >> E;
    for (int i = 0; i < E; i++) {
        int u, v, c;
        cin >> u >> v >> c;
        add_edge(u, v, c);
    }

    cout << max_flow(0, V-1) << endl;

    return 0;
}


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

int main(){
double w,h,x,y,s;
cin >> w >> h >> x >> y;
cout << (w*h)/2 << endl;
if(w/2 == x && h/2 == y)
cout << "1" << endl;
else
{
    cout << "0" << endl;
}


}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, M);
    AIN(ll, H, N);
    A2IN(ll, A, ll, B, M);
    vvi X(N + 1);
    REP(i, M)
    {
        X[A[i]].push_back(B[i]);
        X[B[i]].push_back(A[i]);
    }
    ll ans = 0;
    REP1(i, N)
    {
        bool ok = true;
        FOR(j, X[i])
        {
            ok &= H[i - 1] > H[j - 1];
        }
        ans += ok;
    }
    OUT(ans);
}

Measured memory_bytes: 11444
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	long long N,A,B;
	long long solution;
	cin >> N >> A >> B;
	if(A == 0) cout << 0;
	else if(B == 0) cout << N;
	else 
	{
		solution = A * ((long long)(N/(A+B)))
		+ min((N%(A+B)),A);
		cout << solution;
	}
	return 0;
}

Measured memory_bytes: 256
/** BiSmIlLaHiR rAhMaNiR rAhIm **\

*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*
*$*                                             *$*
*$*    ||||||||  ||||||||  ||||||||  ||||||||   *$*
*$*    ||    ||  ||           ||     ||         *$*
*$*    ||||||||  ||||||||     ||     ||||||     *$*
*$*    ||    ||        ||     ||     ||         *$*
*$*    ||    ||  ||||||||  ||||||||  ||         *$*
*$*                                             *$*
*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*

            \**  DIIT(17th batch) **/

#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define pf printf
#define sf scanf
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define makep make_pair
#define MOD 1000000007
#define PI 2*acos(0.0)
#define PII pair<ll, ll>
#define pii pair<int, int>
#define what_is(x) cerr<<#x<<" is "<<x<<endl;
#define fio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    fio();
    ll a,b;
    cin>>a>>b;
    if(abs(a-b)==0||abs(a-b)==1)
        cout<<"Yay!\n";
    else
        cout<<":(\n";
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

#define X first
#define Y second

const int N=3e5+10;
const ll inf=1e16;
priority_queue <int> pq;


int n,a[N];
ll fL[N],fR[N];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=3*n;i++) scanf("%d",a+i);

    ll Lsum=0;
    for(int i=1;i<=n;i++) pq.push(-a[i]),Lsum+=a[i];
    fL[n]=Lsum;
//    cout<<Lsum<<'\n';
    for(int i=n+1;i<=2*n;i++){
        Lsum+=a[i];
//        cout<<i<<" "<<Lsum<<'\n';
        pq.push(-a[i]);
        Lsum-=-pq.top();pq.pop();
        fL[i]=Lsum;
//        cout<<i<<" "<<fL[i]<<'\n';
    }
    while (!pq.empty()) pq.pop();

    ll Rsum=0;
    for(int i=0;i<n;i++) pq.push(a[3*n-i]),Rsum+=a[3*n-i];
    fR[2*n+1]=Rsum;
    for(int i=n;i<=2*n;i++){
        Rsum+=a[3*n-i];
        pq.push(a[3*n-i]);
        Rsum-=pq.top();pq.pop();
        fR[3*n-i]=Rsum;
    }
    ll ans=-inf;
    for(int i=n;i<=2*n;i++) ans=max(ans,fL[i]-fR[i+1]);
    cout<<ans;
}


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

int main(){

int N,T,k=0;

cin >> N;
if(N<=111)cout << 111 << endl;
else if(N<=222)cout << 222 << endl;
else if(N<=333)cout << 333 << endl;
else if(N<=444)cout << 444 << endl;
else if(N<=555)cout << 555 << endl;
else if(N<=666)cout << 666 << endl;
else if(N<=777)cout << 777 << endl;
else if(N<=888)cout << 888 << endl;
else if(N<=999)cout << 999 << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<int> ga[100010];
int a,b;
int indeg[100010];
int ancest[100010];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=(n-1+m);i++){
		cin>>a>>b;
		ga[a].push_back(b);
		indeg[b]++;
	}
	stack<int> S;
	for(int i=1;i<=n;i++)
	   if(indeg[i]==0)
	   {
		  ancest[i]=0;
		  S.push(i);
	   }
	while(!S.empty()){
		int cur=S.top();
		S.pop();
		for(int i=0;i<ga[cur].size();i++){
			indeg[ga[cur][i]]--;
			if(indeg[ga[cur][i]]==0){
				S.push(ga[cur][i]);
				ancest[ga[cur][i]]=cur;
			}
		}
	}
	for(int i=1;i<=n;i++)
	   cout<<ancest[i]<<endl;
	return 0;
}


Measured memory_bytes: 7040
#include <cstdio>
#include <bitset>
#include <cmath>
#include <complex>
#include <vector>
#include <algorithm>

#define EPS 1e-6

using namespace std;
typedef complex<double> coor;

double cross(coor a, coor b)
{
  return a.real() * b.imag() - a.imag() * b.real();
}

double dot(coor a, coor b)
{
  return a.real() * b.real() + a.imag() * b.imag();
}

int main()
{
  double _x[3][2], _p[2];
  while (scanf(" %lf %lf %lf %lf %lf %lf %lf %lf ", &_x[0][0], &_x[0][1], &_x[1][0], &_x[1][1], &_x[2][0], &_x[2][1], &_p[0], &_p[1]) == 8) {
    coor x[3], g(0, 0);
    for (int i = 0; i < 3; i++) {
      x[i] = coor(_x[i][0], _x[i][1]);
      g += x[i];
    }
    g /= 3;
    coor p = coor(_p[0], _p[1]);
    coor d;
    for (int i = 0; i < 3; i++) {
      d = x[(i + 1) % 3] - x[i];
      if ((dot(d * coor(0, 1), g) - dot(d * coor(0, 1), x[i])) * (dot(d * coor(0, 1), p) - dot(d * coor(0, 1), x[i])) < 0) {
	printf("NO\n");
	goto next;
      }
    }
    printf("YES\n");
  next:;
  }
}

Measured memory_bytes: 0
class PriorityQueue
  def initialize(&comp)
    @heap = []
    @node_num = 0
    if !block_given?
      @comp = Proc.new { |x, y| x <= y }
    else
      @comp = comp
    end
  end
  attr_reader :heap

  def push(x)
    i = @node_num # 自分のノード番号
    @node_num += 1
    while i > 0
      par = (i - 1) / 2 # 親のノード番号
      break if @comp.call(@heap[par], x) # 逆転してないなら抜ける
      # 親ノードを下ろして自分を上に
      @heap[i] = @heap[par]
      i = par
    end
    @heap[i] = x
  end

  alias_method(:<<, :push)

  def pop
    # 最(小|大)値
    ret = @heap[0]
    # 根にもってくる値
    @node_num -= 1
    x = @heap[@node_num]
    # 根から下ろしていく
    i = 0
    while i * 2 + 1 < @node_num
      # 子どうしを比較
      a = i * 2 + 1
      b = i * 2 + 2
      a = b if b < @node_num && !@comp.call(@heap[a], @heap[b])
      break if @comp.call(x, @heap[a])
      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    ret
  end

  def get
    @node_num == 0 ? nil : @heap[0]
  end

  def empty?
    get.nil?
  end
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
q = PriorityQueue.new { |x, y| x > y }
a.each do |e|
  q.push e
end

m.times do
  q.push(q.pop / 2)
end
puts q.heap.inject(:+)


Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n,m,x;
  cin>>n>>m;
  if(n%m!=0)cout<<1<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "-1" << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(){
    int M,D;
    cin >> M >> D;
    int Ans=0;
    REP(i,M+1){
        if(i<=1)continue;
        REP(j,D+1){
            if(j<=9)continue;
            if((j/10)==1 || (j%10)==1)continue;
            if((j/10)*(j%10)==i){
                Ans++;
                //cout << i MM j << endl;
            }
        }
    }
    cout << Ans << endl;
    return 0;
}   


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

using namespace std;

#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)



int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//code
	ll n,m;
	cin >> n >> m;
	if(n%m) cout << "1" << endl;
	else cout << "0" << endl;	
	return 0;

}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    string S;
    cin >> S;
    rep(i, S.length()) {
        if (i % 2 == 0) {
            if (S[i] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (S[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  REP(i, 26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  REP(i, D) { REP(j, 26) cin >> s[i][j]; }
  ll score = 0;
  vector<ll> ans(0);
  unordered_map<int, int> lastday{};
  REP(i, D) {
    vector<pair<ll, int>> tmp(26);
    REP(j, 26) {
      //貪欲に選ぶ
      tmp[j].first = score + s[i][j];
      tmp[j].second = j;
      REP(k, 26) {
        if (j == k) continue;
        tmp[j].first -= c[k] * (i + 1 - lastday[k]);
      }
    }
    sort(tmp.begin(), tmp.end());
    ans.push_back(tmp[25].second);
  }
  REP(i, D) { cout << ans[i] + 1 << endl; }
}


Measured memory_bytes: 3692
#if 0
最も期待値の大きな区間から金がなくなるまで守ってもらう.
#endif

#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

struct Item
{
    int d; /* 距離 */
    int p; /* 期待値 */
};

int N /* 区間の数 */,
    M /* 予算 */,
    D_SUM /* 区間の距離合計 */,
    P_SUM /* 区間の期待値合計 */;
vector<Item>
    P /* 単位距離あたりの期待値の構造体 */;

// 昇順
bool cmp(const Item &a, const Item &b)
{
    return a.p == b.p ? a.d < b.d : a.p < b.p;
}

int main()
{
    while (cin >> N >> M && !(N == 0 && M == 0))
    {
        D_SUM = 0;
        P_SUM = 0;
        for (int i = 0; i < N; i++)
        {
            Item a;
            cin >> a.d >> a.p;
            D_SUM += a.d;
            P_SUM += a.p * a.d;
            P.push_back(a);
        }
        sort(P.begin(), P.end(), cmp);
        if (D_SUM <= M)
        {
            // かかる金額の合計値が予算以下の場合
            P.clear();
            cout << 0 << endl;
            continue;
        }
        // 予算内では全ての区間で護衛が付けられない場合
        int DIFF = D_SUM - M; // 護衛を付けられない区間の合計
        int result = 0;
        int not_defensed_distance = 0;
        for (auto x : P)
        {
            int sum = not_defensed_distance + x.d;
            if (sum >= DIFF)
            {
                result += (DIFF - not_defensed_distance) * x.p;
                break;
            }
            else
            {
                result += x.d * x.p;
                not_defensed_distance += x.d;
            }
        }
        P.clear();
        cout << result << endl;
    }
}



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


int main() {
  int a, b, ans=0;
  char op;
  cin >> a >> op >> b;
  if(op == '+') ans = a + b;
  else ans = a - b;
    
  cout << ans << endl;  
  return 0;
  
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	string s, t, u;
	cout << 0 << endl;
	cin >> s;
	if (s[0] == 'V')
		return 0;
	cout << n - 1 << endl;
	cin >> t;
	if (t[0] == 'V')
		return 0;
	int l = 0, r = n - 1;
	for (;;) {
		int m = (l + r) / 2;
		cout << m << endl;
		cin >> u;
		if (u[0] == 'V')
			return 0;
		if ((s == u) == (m - l) % 2) {
			r = m;
			t = u;
		}
		else l = m, s = u;
	}
	return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
typedef pair<ll, ll> P;
typedef map<string, ll> M;
typedef unordered_map<ll, ll> HM;
typedef set<ll> S;
typedef multiset<ll> MS;
typedef queue<ll> Q;

int main(){
    ll n; cin>>n;
    ll h[n];
    for(ll i=0; i<n; i++)
        cin >> h[i];
    for(ll i=n-2; i>=0; i--){
        if(h[i]<=h[i+1])
            continue;
        else if(h[i] == h[i+1]+1)
            h[i]--;
        else{
            OUT("No");
            return 0;
        }
    }
    OUT("Yes");
}

Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

ll dp[30][60000], exist[30][30], cost[30][30], three[12];

int main() {
    int N; cin >> N;
    for(int i=0; i<N; i++) {
        char u; ll v; cin >> u >> v;
        exist[u-'A'][v] = true;
    }
    
    
    int M; cin >> M;
    fill(cost[0], cost[28], LONGINF);
    for(int i=0; i<M; i++) {
        char x; ll y, z; cin >> x >> y >> z;
        chmin(cost[x-'A'][y], z);
    }

    three[0] = 1;
    for(int i=1; i<=10; i++) three[i] = three[i-1] * 3;

    fill(dp[0], dp[28], LONGINF);
    dp[0][0] = 0;
    for(int i=0; i<26; i++) {
        for(int bit=0; bit<three[10]; bit++) {
            if(dp[i][bit] == LONGINF) continue;
            for(int d=0; d<10; d++) {
                int nbit = bit - (bit%three[d+1]/three[d]*three[d]) + three[d]*2;
                chmin(dp[i][nbit], dp[i][bit] + cost[i][d]);
                chmin(dp[i+1][nbit], dp[i][bit] + cost[i][d]);
            }

            int b = bit;
            for(int d=0; d<10; d++) {
                if(!exist[i][d] or b%three[d+1]/three[d] != 0) continue;
                b += three[d];
            }

            chmin(dp[i+1][b], dp[i][bit]);
        }
    }

    ll ans = LONGINF;
    for(int bit=0; bit<three[10]; bit++) {
        bool ok = true;
        for(int d=0; d<10; d++) {
            if(bit%three[d+1]/three[d] == 1) {
                ok = false;
                break;
            }
        }

        if(ok) chmin(ans, dp[26][bit]);
    }
    if(ans == LONGINF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}



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

void Add(int &a, int b) {
  a += b;
  while (a >= MOD) a -= MOD;
  while (a < 0) a += MOD;
}
 
void Mul(int &a, int b) {
  a = 1LL * a * b % MOD;
}
 
int Pow(int b, int e) {
  if (e < 0) e += MOD - 1;
  int ret = 1;
  while (e) {
    if (e & 1) ret = 1LL * ret * b % MOD;
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return ret;
}
 
namespace Math {
  const int NMAX = (int)1e6;
  int pow2[1 + NMAX];
  int fact[1 + NMAX], tcaf[1 + NMAX];
  void Precalc() {
    fact[0] = pow2[0] = 1;
    for (int i = 1; i <= NMAX; ++i) {
      pow2[i] = pow2[i - 1];
      Add(pow2[i], pow2[i]);
 
      fact[i] = fact[i - 1];
      Mul(fact[i], i);
    }
    tcaf[NMAX] = Pow(fact[NMAX], -1);
    for (int i = NMAX - 1; i >= 0; --i) {
      tcaf[i] = tcaf[i + 1];
      Mul(tcaf[i], i + 1);
      assert(1LL * fact[i] * tcaf[i] % MOD == 1);
    }
  }
  int Choose(int n, int k) {
    if (k > n || n < 0) return 0;
    return 1LL * fact[n] * tcaf[n - k] % MOD * tcaf[k] % MOD;
  }
};

int main() {
    ll n;
    cin >> n;
    Math::Precalc();
    vector<ll> a(n),b(n-1),p(n+1);
    ll y=1;
    p[0]=0;
    vector<ll> k(n+1);
    k[0]=1;
    for(ll i=0;i<n;i++){
      k[i+1]=(k[i]*(i+1ll))%MOD;
    }
    rep(i,n){
      p[i+1]=(p[i]+Pow(y,MOD-2)*k[n-1])%MOD;
      y++;
    }
    rep(i,n) cin >> a[i];
    rep(i,n-1) b[i]=a[i+1]-a[i];
    ll ans=0;
    for(ll i=0;i<n-1;i++){
      (ans+=b[i]*p[i+1]%MOD)%=MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 15104
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
A = [a-1 for a in A]

ptr = 0
cnt = 0
visited = [-1 for i in range(N)]
visited[0] = 0
for i in range(N):
  nxt = A[ptr]
  if visited[nxt] != -1:
    break
  else:
    cnt += 1
    ptr = nxt
    visited[nxt] = cnt
visited = [(i,v) for i,v in enumerate(visited) if v!=-1]
visited = [i for i,v in sorted(visited,key=lambda x:x[1])]
idx = visited.index(nxt)
loop = len(visited)-idx
calc = K if K < len(visited) else (idx + (K-idx)%loop )
print(visited[calc]+1)

Measured memory_bytes: 127496
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int x;
    cin >> x;
    int ans = 0;
    ans += x / 500 * 1000;
    ans += (x % 500) / 5 * 5;
    print(ans);

    return 0;
}



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

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

Measured memory_bytes: 3680
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    if (n == 5 || n == 3 || n == 7){
        cout << "YES"<< endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>

using namespace std;
typedef long long  ll;

const ll mod = 1000000007;

int main()
{
	ll N;
	cin >> N;
	vector<ll> a(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	bool flag = false;
	stack <ll> que;
	for (ll i = 0; i < N; i++)
	{
		for (ll j = a.size() - 1; j >= 0; j--)
		{
			if (a[j] == j + 1LL)
			{
				a.erase(a.begin() + j);
				que.push(j + 1LL);
				flag = true;
				break;
			}
		}
		if (!flag) {
			cout << -1 << endl;
			return 0;
		}
		flag = false;
	}
	while (!que.empty())
	{
		cout << que.top() << endl;
		que.pop();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
#define int long long
using ll = long long;
const ll mod = LLONG_MAX;

signed main(){
  int n,m;
  cin>>n>>m;
  cout<<(1900*m+100*(n-m))*pow(2,m)<<endl;


}


Measured memory_bytes: 512
### constant

MAX_W = MAX_H = 7
INF = 1 << 30
DXYS = [[1, 0], [0, -1], [-1, 0], [0, 1]]

### subroutines

def paint(w, h, flds)
  cls = (w * h).times.map{0}
  cl = 1

  for y0 in (0...h)
    for x0 in (0...w)
      pos0 = y0 * w + x0
      if flds[pos0] && cls[pos0] == 0
        cls[pos0] = cl
        q = [pos0]

        while ! q.empty?
          u = q.shift
          ux = u % w
          uy = u / w
          DXYS.each do |dx, dy|
            vx = ux + dx
            vy = uy + dy
            v = vy * w + vx
            if vx >= 0 && vx < w && vy >= 0 && vy < h &&
               flds[v] && cls[v] == 0
              cls[v] = cl
              q << v
            end
          end
        end

        cl += 1
      end
    end
  end
  
  cls
end

### main

loop do
  w, h = gets.split.map(&:to_i)
  break if (w | h) == 0

  wh = w * h
  flds = wh.times.map{true}
  cpos = gpos = mpos = nil
  
  for y in (0...h)
    line = gets.split.map(&:to_i)
    for x in (0...w)
      pos = y * w + x
      case line[x]
      when 1
        flds[pos] = false
      when 2
        cpos = pos
      when 3
        gpos = pos
      when 4
        mpos = pos
      end
    end
  end
  #p flds
  #p [cpos, gpos, mpos]
  
  edges = wh.times.map{wh.times.map{wh.times.map{false}}}
  
  for y in (0...h)
    for x in (0...w)
      cpos0 = y * w + x
      if flds[cpos0]
        flds[cpos0] = false
        cls = paint(w, h, flds)
        flds[cpos0] = true

        for pos0 in (0...wh)
          cl0 = cls[pos0]
          next if cl0 == 0
          for pos1 in (pos0...wh)
            if cls[pos1] == cl0
              edges[cpos0][pos0][pos1] = edges[cpos0][pos1][pos0] = true
            end
          end
        end
      end
    end
  end
  #p edges
  
  dists = wh.times.map{wh.times.map{INF}}
  dists[cpos][mpos] = 0
  q = [[cpos, mpos]]

  while ! q.empty?
    uc, um = q.shift
    break if uc == gpos

    ucx = uc % w
    ucy = uc / w
    nvd = dists[uc][um] + 1

    DXYS.each do |dx, dy|
      vcx = ucx + dx
      vcy = ucy + dy
      vc = vcy * w + vcx

      vmx = ucx - dx
      vmy = ucy - dy
      vm = vmy * w + vmx
      #p [vcx, vcy, vmx, vmy, flds[vc], flds[vm], edges[uc][um][vm]]
      
      if vcx >= 0 && vcx < w && vcy >= 0 && vcy < h && flds[vc] &&
         vmx >= 0 && vmx < w && vmy >= 0 && vmy < h && flds[vm] &&
         edges[uc][um][vm]
        if dists[vc][uc] >= INF
          dists[vc][uc] = nvd
          q << [vc, uc]
          #p [vcx, vcy, ucx, ucy, dists[vc][uc]]
        end
      end
    end
  end

  mind = dists[gpos].min
  puts (mind >= INF ? -1 : mind)
end

Measured memory_bytes: 7068
package main

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

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

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

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

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

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

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

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

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

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

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	k := getNextInt(scanner)
	var ans int64
	for a := 0; a < k; a++ {
		for b := 0; b < k; b++ {
			for c := 0; c < k; c++ {
				ans += int64(gcd(a+1, gcd(b+1, c+1)))
			}
		}
	}
	fmt.Fprintln(writer, ans)
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 1836
s = input()
n = len(s)
for i in range(n - 1):
    if s[i] == s[i + 1]:
        exit(print(i + 1, i + 2))
for i in range(n - 2):
    if s[i] == s[i + 2]:
        exit(print(i + 1, i + 3))
print(-1, -1)

Measured memory_bytes: 9232
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7

def sol():
    N, X = map(int, input().split())

    ans = N
    A = max(N - X, X)
    B = min(N - X, X)

    while B:
        q = A // B
        r = A % B

        ans += B * 2 * q
        if r == 0:
            ans -= B

        A = B
        B = r

    print(ans)

sol()

Measured memory_bytes: 3444
#include"bits/stdc++.h"
using namespace std;
int n;
vector<int> num;
bool flag()
{
	for(int i=0;i<n;i++)
	{
		if(num[i]%2==1)
		{
			return false;
		}
	}
	return true;
}
int main()
{
	int i,j;
	scanf("%d",&n);
	num.resize(n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
	}
	for(i=0;;i++)
	{
		if(flag())
		{
			for(j=0;j<n;j++)
			{
				num[j]/=2;
			}
		}
		else
		{
			break;
		}
	}
	printf("%d",i);
} 

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string s;
    cin >> s;

    int ans = 0;
    int cnt = 0;
    REP(i, s.size()) {
        if (s[i] == 'R') {
            cnt++;
            ans = max(ans, cnt);
        } else {
            cnt = 0;
        }
    }

    print(ans);
}


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

vector<int> input(int N){
    int i;
    vector<int> output(N);
    for(i=0;i<N;i++)cin>>output[i];
    return output;
}

int main(){
    int N,K;
    int result=1;
    vector<int> A;
    cin>>N>>K;
    A=input(N);

    if((N-K)%(K-1)==0){
        cout<<result+(N-K)/(K-1)<<endl;;
    }else{
        cout<<result+(N-K)/(K-1)+1<<endl;
    }
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
int dp[8][4096], n;

int main()
{
        for (int i = 0; i <= 1000; i++) dp[1][i] = 1;
        for (int i = 1; i < 3; i++)
                for (int j = 0; j <= 1000*i; j++)
                        for (int k = 0; k <= 1000*i; k++)
                                dp[i*2][j+k] += dp[i][j]*dp[i][k];

        while(cin >> n) cout << dp[4][n] << endl;
        return 0;
}

Measured memory_bytes: 3128