akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

string map[8];
int dx[] = { -3, -2, -1, 1, 2, 3, 0, 0, 0, 0, 0, 0 };
int dy[] = { 0, 0, 0, 0, 0, 0, -3, -2, -1, 1, 2, 3 };

int chk(int x, int y)
{
	return x<0||y<0||x>=8||y>=8;
}

void dfs(int x, int y)
{
	if (map[y][x] == '0') return;

	map[y][x] = '0';
	for (int i=0; i<12; i++)
	{
		int nx=x+dx[i], ny=y+dy[i];
		if (chk(nx, ny))
			continue;

		if (map[ny][nx] == '1')
			dfs(nx, ny);
	}
}

int main()
{
	int X = 1;
	int N;
	cin >> N;
	while (N--)
	{
		for (int y=0; y<8; y++)
			cin >> map[y];

		int sx, sy;
		cin >> sx >> sy;
		dfs(--sx, --sy);

		cout << "Data " << X++ << ":" << endl;
		for (int y=0; y<8; y++)
			cout << map[y] << endl;
	}
}

Measured memory_bytes: 0
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {

        let mut 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)*}
    };
}

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,
        t: chars,
    }
    let mut ans = vec![];
    'outer: for i in 0..s.len() - t.len() + 1 {
        let mut ptn = s.clone();
        for j in 0..t.len() {
            if s[i + j] != t[j] && s[i + j] != '?' {
                continue 'outer;
            }
            if s[i + j] == '?' {
                ptn[i + j] = t[j];
            }
        }
        // println!("{:?}", ptn);

        let ptn = ptn
            .iter()
            .map(|&c| if c == '?' { 'a' } else { c })
            .collect::<Vec<char>>();
        if ans.len() == 0 {
            ans = ptn;
        } else {
            ans = std::cmp::min(ans, ptn);
        }
    }
    if ans.len() == 0 {
        println!("{}", "UNRESTORABLE");
    } else {
        println!("{}", ans.into_iter().collect::<String>());
    }
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void){
    int n;
    scanf("%d",&n);

    if(n == 1 || n == 0)
        printf("1\n");
    else{
        long long pre1 = 1,pre2 = 1,ans = 0;
        for(int i = 2;i <= n;i++){
            ans = pre1 + pre2;
            pre2 = pre1;
            pre1 = ans;
        }
        printf("%lld\n",ans);
    }
    return 0;
}

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


int main() {
  int N;
  cin>>N;
  vector<vector<int>> vec(N, vector<int>(26)); 
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    for(int j=0;j<S.size();j++){
      vec.at(i).at(S.at(j)-97)+=1;
    }
  }
  vector<int> kaz(26);
  for(int i=0;i<26;i++){
    int mi=100;
    for(int j=0;j<N;j++){
      mi=min(mi,vec.at(j).at(i));
    }
    kaz.at(i)=mi;
  }
  for(int i=0;i<26;i++){
    for(int j=0;j<kaz.at(i);j++){
      cout<<char(i+97);
    }
  }
  cout<<endl;
      
    
  
  
  
}

Measured memory_bytes: 3628
def gcd(a,b):
	while b:
		a,b=b,a%b
	return a

t=int(input())
for i in range(t):
	a,b,c,d=map(int,input().split())
	if a<b or b>d:
		print("No")
	elif b<=c:
		print("Yes")
	else:
		g=gcd(b,d)
		if (g-a%g)>=b-c:
			print("Yes")
		else:
			print("No")


Measured memory_bytes: 3060
from math import gcd

MOD = 10**9+7
N = int(input())
d = {}
zero = 0
for i in range(N):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zero += 1
        continue

    if a < 0 or a == 0 and b < 0:
        a, b = -a, -b
    if b <= 0:
        a, b = -b, a
        flip = 1
    else:
        flip = 0

    g = gcd(a, b)
    a //= g
    b //= g
    if not (a, b) in d:
        d[(a, b)] = [0, 0]
    d[(a, b)][flip] += 1

ans = 1
for (v1, v2) in d.values():
    ans *= pow(2, v1, MOD) + pow(2, v2, MOD)-1
    ans %= MOD
ans -= 1
ans += zero
ans %= MOD
print(ans)


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

int main()
{
	int a, b, c,x,y,z;
	cin >> a >> b >> c;
	x = a + b;
	y = b + c;
	z = c + a;

	if (x <= y && x <= z)
		cout << x<<endl;

	else if (y <= x && y <= z)
		cout << y<<endl;

	else
		cout << z<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, d;
int main()
{
    cin >> n >> a >> b >> c >> d;
    b -= a; n --;
    for (int i = 0; i <= n; ++ i)
        if (1ll * i * d - 1ll * (n - i) * c >= b && 1ll * i * c - 1ll * (n - i) * d <= b)
            return puts("YES"), 0;
    puts("NO");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int x;  cin >> x;
    cout << 1 -x << endl;
    return 0;
}

Measured memory_bytes: 3628
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

pii p1, p2;
int H,W, grid[202][202];
int parent[202], max_flow = 0;   

bool bfs() {
    bool visited[202];
    memset(visited, 0, sizeof(visited));
 
    queue <int> q;
    q.push(0);
    visited[0] = true;
    parent[0] = -1;
 
    // Standard BFS Loop
    while (!q.empty()) {
        int u = q.front();
        q.pop();
 
        for (int v=0; v<202; v++) {
            if (visited[v]==false && grid[u][v] > 0) {
                q.push(v);
                parent[v] = u;
                visited[v] = true;
            }
        }
    }
 
    return (visited[201] == true);
}
 
int fordFulkerson() {
    int u,v;
    while (bfs()) {
        int path_flow = INT_MAX;
        for (v=201; v != 0; v=parent[v]) {
            u = parent[v];
            path_flow = min(path_flow, grid[u][v]);
        }
 
        for (v=201; v != 0; v=parent[v]) {
            u = parent[v];
            grid[u][v] -= path_flow;
            grid[v][u] += path_flow;
        }
 
        max_flow += path_flow;
    }
 
    // Return the overall flow
    return max_flow;
}

int main() {
	cin >> H >> W;
	FOR(i,1,H+1) {
	    FOR(j,1,W+1) {
	        char c; cin >> c;
	        if (c == 'S') {
	            p1 = {i,j};
	            grid[0][i] = grid[0][j+100] = MOD;
	        } else if (c == 'T') {
	            p2 = {i,j};
	            grid[i][201] = grid[j+100][201] = MOD;
	        } else if (c == 'o') grid[i][j+100] = grid[j+100][i] = 1;
	    }
	}
	if (p1.f == p2.f || p1.s == p2.s) {
	    cout << -1;
	    return 0;
	}
	cout << fordFulkerson();
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int n;

void dfs(int x = 1, string s = "a", char c = 'a'){
    if(x == n){
        cout << s << endl;
        return;
    }
    for(char i = 'a'; i <=c + 1; i++){
        if(i <= c){
            dfs(x + 1, s + i, c);
        }else{
            dfs(x + 1, s + i, c + 1);
        }
    }
}

int main(){
    cin >> n;
    dfs();
    return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


//-----------------------------------------------------------------------------

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

	int a,b;cin>>a>>b;cout<<(a+b)%24<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++) 
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++) 
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//const ll mod = 1000000007;
//const ll INF = mod * mod;
//const double pi = 3.14159265358979;

int main() {
    string s,t;
    cin >> s >> t;
    string r = s;
    int n = s.size();
    int m = t.size();
    int limit = n - m + 1;
    vi v;
    rep(i,limit) {
        string a = s.substr(i,m);
        //cout << a << endl;
        bool ok = true;
        rep(j,m) {
            if(a[j] != '?' && a[j] != t[j]) ok = false;
        }
        if(ok) v.pb(i);
    }
    if(v.size() == 0) {
        puts("UNRESTORABLE");
        return 0;
    }
    vs ans; 
    rep(i,v.size()) {
        int x = v[i];
        for(int j = x; j < x+m; j++) {
            s[j] = t[j-x];
        }
        rep(j,n) {
            if(s[j] == '?') s[j] = 'a';
        }
        ans.pb(s);
        s = r;
    }
    sort(all(ans));
    cout << ans[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX (1000000000000000000ll)
#define MIN (-1000000000000000000ll)

using namespace std;

int main()
{
    long long a, b, c;
    long long k;

    cin >> a >> b >> c;
    cin >> k;

    if ( k % 2 == 1 ) {
        cout << b - a << endl;
    } else {
        cout << a - b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.parseInt(br.readLine());
        String line[] = br.readLine().split(" ");
        long sum = 0;
        int max = -1000000;
        int min = 1000000;
        int tmp;
        for (int i = 0; i < num; i++) {
            tmp = Integer.parseInt(line[i]);
            if (tmp > max) {
                max = tmp;
            }
            if (tmp < min) {
                min = tmp;
            }
            sum +=tmp;
        }
        System.out.println(min + " "+max +" "+sum);
    }
}

Measured memory_bytes: 28600
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    int sum=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        sum+=a[i];
    }
    int sqn=sqrt(sum);
    vector<int> f;
    for(int i=1; i<=sqn; i++){
        if(sum%i==0){
            f.push_back(i);
            f.push_back(sum/i);
        }
    }
    sort(f.rbegin(),f.rend());
    for(int ff : f){
        int i=ff;
        vector<int> v(n);
        for(int j=0; j<n; j++) v[j]=a[j]%i;
        sort(v.begin(),v.end());
        int k1=0,k2=n-1;
        int nowk=0;
        while(k1<k2){
            int cnt=min(v[k1],i-v[k2]);
            nowk+=cnt;
            if(nowk>k) break;
            v[k1]-=cnt;
            v[k2]+=cnt;
            if(v[k1]==0) k1+=1;
            if(v[k2]==i) k2-=1;
        }
        if(v[k1]%i==0 && v[k2]%i==0 && k-nowk>=0){
            cout<<i;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
from sys import stderr, setrecursionlimit
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*args, sep=" ", end="\n"):
    for item in args:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

h, w = getInts()
grid = [['.' for _ in range(w+2)]]
for _ in range(h):
    tmp = ['.']
    tmp.extend(list(input()))
    tmp.append('.')
    grid.append(tmp)
grid.append(['.' for _ in range(w+2)])

for i in range(1,h+1):
    for j in range(1,w+1):
        if grid[i][j] == '#':
            continue
        count = 0
        for k in range(-1,2):
            for l in range(-1,2):
                if grid[i+k][j+l] == '#':
                    count += 1
        grid[i][j] = count
for l in grid[1:-1]:
    print(*l[1:-1], sep='')


Measured memory_bytes: 3572
#define _GLIBCXX_DEBUG
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef map<int, int> mii;
    typedef map<char,int> mci;
    typedef vector<int> vi;
    typedef vector<vi> vvi;
    typedef vector<ll> vll;
    typedef vector<pair<int,int>> vii;
    typedef vector<char> vc;
    typedef vector<vc> vcc;
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()
    #define pb push_back
    #define mp make_pair
    #define F first
    #define S second
    #define in insert
    #define sz(v) v.size()
    #define mina(a,b) (a)=min((a),(b));
    #define maxa(a,b) (a)=max((a),(b));
    const int INF = 1e9 + 5;
    
    void solve(){
        int n, m;  cin>>n>>m;
        int maxl=0,minr=n+1;
        for(int i = 1; i <= m; i++){
            int l,r; cin>>l>>r;
            maxa(maxl,l);
            mina(minr,r);
        }
        if(maxl>minr) cout<<0;
        else cout<<minr-maxl+1;
    }
    int main(){
        int T=1;
        //cin>>T;
        for(int i = 0; i < T; i++) solve(); 
    }

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H)
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}


Measured memory_bytes: 2116
N = int(input())
As = [0] + list(map(int, input().split()))
Bs = [0] + list(map(int, input().split()))
Cs = [0, 0] + list(map(int, input().split()))
ans = Bs[As[1]]
for i in range(2, N+1):
  ans += Bs[As[i]]
  if As[i] == As[i-1] + 1:
    ans += Cs[As[i]]
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int m,d;
    cin>>m>>d;
    int o=0;
    for(int i=22;i<=d;i++){
        if(((i/10)*(i%10))<=m&&(i%10)>=2&&(i/10)>=2){
            o++;
        }

    }
    cout << o << endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void){
  long long int n, m, count = 0;
  scanf("%lld %lld", &n, &m);

  int tmp;
  if(n > m){
    tmp = n;
    n=m;
    m=tmp;
  }

  if(n==1){
    if(m <= 2){
      count = m%2;
    }else{
      count = m-2;
    }
  }else if(n==2){
      count = 0;
  }else if(n>2){
    count = (n-2)*(m-2);
  }
  
  
  printf("%lld\n", count);
  
  return 0;
}


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

namespace ABC108_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var i = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var x1 = i[0];
            var y1 = i[1];
            var x2 = i[2];
            var y2 = i[3];

            var xd = x2 - x1;
            var yd = y2 - y1;

            Console.WriteLine("{0} {1} {2} {3}", x2 - yd, y2 + xd, x1 - yd, y1 + xd);
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include <string>
#include<vector>
typedef long long ll;

using namespace std;
int main()
{
	int h,w;
	cin >> h>>w;
	vector<string> ss(h);
	for (int i = 0; i < h; i++) {
		cin >> ss[i];
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (ss[i][j] == '#') {
				cout << '#';
				continue;
			}
			int temp = 0;
			if (0<=i-1 && 0<=j-1 && ss[i - 1][j - 1] == '#') temp++;
			if (0 <= i - 1 && ss[i - 1][j] == '#') temp++;
			if (0 <= i - 1 &&j + 1<w && ss[i - 1][j + 1] == '#') temp++;
			if (0 <= j - 1 && ss[i][j - 1] == '#') temp++;
			if (j + 1<w && ss[i][j + 1] == '#') temp++;
			if (i + 1<h && 0 <= j - 1 && ss[i + 1][j - 1] == '#') temp++;
			if (i + 1< h  && ss[i + 1][j] == '#') temp++;
			if (i + 1< h && j + 1<w && ss[i + 1][j + 1] == '#') temp++;
			cout << temp;
		}
		cout << endl;
	}
	cout ;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 10000

int main(){
  int i,j,num=0,count=0,sosu[N],ch=0;
  int hata=0;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    scanf("%d",&sosu[i]);
  }

  for(i=0;i<num;i++){
    ch=(int)sqrt(sosu[i]);
    for(j=2;j<=ch;j++){
      if(sosu[i]%j==0){
	hata=1;
	break;
      }
    }
    if(hata==0)count++;
    hata=0;
  }
 
  printf("%d\n",count);
  return 0;
}




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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d) {
        cout << "Yes" << endl;
    }
    else if (abs(a- b) <= d && abs(b - c) <= d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

int h, w, a, b;
int main() {
	cin >> h >> w >> a >> b;
	rep(i, h) {
		rep(j, w) {
			if (i < b && j < a || b <= i && a <= j) printf("0");
			else printf("1");
		}
		if (i < h - 1) printf("\n");
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < N; i++) {
        if(A[i] % 2 == 0 && (A[i] % 3 != 0 && A[i] % 5 != 0)) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,ll> P;


int main(void){
    int a,b;
    cin>>a>>b;
    if(a==1){
        if(b==2)cout<<3<<endl;
        else cout<<2<<endl;
    }
    else{
        if(a==2){
            if(b==1)cout<<3<<endl;
            else cout<<1<<endl;
        }
        else{
            if(b==1)cout<<2<<endl;
            else cout<<1<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner ob=new Scanner(System.in);
    int h=ob.nextInt();
    int a=ob.nextInt();
    int t=0;
    for(int i=1;i<=a;i++)
    {
      int c=ob.nextInt();
      t=t+c;
    }
    if(t>=h)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

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

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

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

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

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

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

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

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

struct Plan {
    t: i32,
    x: i32,
    y: i32,
}

fn main() {
    input!(
    n: usize,
    k: [[i32; 4]; n+1]
    );
    let p = Plan { t: 0, x: 0, y: 0 };
    for i in k {
        let d = (i[1] - p.x).abs() + (i[2] - p.y).abs();
        let a = i[0] - p.t;
        if a >= d && (a - d) % 2 == 0 {
            let p = Plan { t: i[0], x: i[1], y: i[2] };
        } else {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
int uf[100000];
int root(int x) {
    if (uf[x] < 0) return x;
    else return uf[x] = root(uf[x]);
}
int size(int x) {
    return -uf[root(x)];
}
void unite(int x, int y) {
    x = root(x), y = root(y);
    if (x == y) return;
    if (uf[x] > uf[y]) swap(x, y);
    uf[x] += uf[y];
    uf[y] = x;
}
long long f(int x) {
    if (x <= 1) return 0;
    return (long long)x * (x-1) / 2;
}
int main()
{
    int N, M; cin >> N >> M;
    vector<long long> A(M), B(M), ans;
    for (int i = 0; i < M; i++) cin >> A[i] >> B[i], A[i]--, B[i]--;
    ans.push_back((long long)N * (N-1) / 2);
    for (int i = 0; i < N; i++) uf[i] = -1;
    for (int i = M-1; i > 0; i--) {
        if (root(A[i]) == root(B[i])) {
            ans.push_back(ans.back());
            continue;
        }
        int a = size(A[i]), b = size(B[i]);
        unite(A[i], B[i]);
        ans.push_back(ans.back() + f(a) + f(b) - f(a + b));
    }
    for (int i = ans.size()-1; i >= 0; i--) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 4212
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int in = s.nextInt();
		s.next();
		String a;
		for(int i=0;i<in;i++) {
			a=s.next();
			System.out.println(a);
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 11372
# include <iostream>
using namespace std;
int n,s;
void work (void)
{
	int p,q;
	p=n;
	while (p>=1)
	{
		q=p%10;
		s=s*10+q;
		p/=10;
	}
	if (s==n)
	cout<<"Yes";
else cout<<"No";
}
int main (void)
{
	cin>>n;
	work ();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> P;

int main(void){
  int up[4]={0,1,0,-1};
  int lf[4]={-1,0,1,0};

  int h,w;cin>>h>>w;
  string s[h];
  for(int i=0;i<h;i++) {
    cin>>s[i];
  }
  int an=0;
  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      if (s[i][j]=='#') continue;
      int nw=0;
      vector<P> q[2]; bool u[h][w]; fill(u[0], u[h], false);
      q[0].push_back({i,j}); u[i][j]=true;
      //cout<<"["<<i<<","<<j<<"]"<<endl;
      while(true) {
        //if (i==0&&j==4)cout<<nw<<endl;
        for(P x:q[nw%2]) {
          for(int k=0;k<4;k++) {
            int xx=x.first+up[k], yy=x.second+lf[k];
            if (0<=xx && xx<h && 0<=yy && yy<w && !u[xx][yy] && s[xx][yy]=='.') {
              q[(nw+1)%2].push_back({xx, yy});
              u[xx][yy]=true;
            }
          }
          //if (i==0&&j==4)cout<<"("<<x.first<<","<<x.second<<") ";
        }
        q[nw%2].clear();
        if (q[(nw+1)%2].empty()) break;
        else nw++;
      }
      an=max(an, nw);
    }
  }
  cout<<an<<endl;
}

Measured memory_bytes: 256
import heapq


def prim(n, s, edges):
    # n:頂点数, s:スタートノード
    # edges: edgeリスト(cost, 行き先ノード)
    used = [False] * n
    edgelist = []
    for e in edges[s]:
        heapq.heappush(edgelist, e)
    used[s] = True
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if used[minedge[1]]:
            continue
        used[minedge[1]] = True
        for e in edges[minedge[1]]:
            if not used[e[1]]:
                heapq.heappush(edgelist, e)
        res += minedge[0]
    return res


N = int(input())
XY = [[i] + list(map(int, input().split()))for i in range(N)]

edges = [[] for _ in range(N)]
sorted_xy = sorted(XY, key=lambda x: x[1])
for i in range(N-1):
    a = sorted_xy[i][0]
    b = sorted_xy[i+1][0]
    cost = sorted_xy[i+1][1] - sorted_xy[i][1]
    edges[a].append((cost, b))
    edges[b].append((cost, a))
sorted_xy = sorted(XY, key=lambda x: x[2])
for i in range(N-1):
    a = sorted_xy[i][0]
    b = sorted_xy[i+1][0]
    cost = sorted_xy[i+1][2] - sorted_xy[i][2]
    edges[a].append((cost, b))
    edges[b].append((cost, a))
ans = prim(N, 0, edges)
print(ans)


Measured memory_bytes: 70956
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int n,m;
	while(1){
		cin>>n>>m;
		if(n==0)break;
		vector<int> d(n),v(n);
		vector<int> val(m,0);
		for(int i=0;i<n;i++){
			cin>>d[i]>>v[i];
			val[d[i]-1] = max(val[d[i]-1] , v[i]);
		}
		int sum = 0;
		for(int i=0;i<m;i++)sum+= val[i];
		cout<<sum<<endl;

	}
	return 0;
}



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

public class Main {

    public static void main(String[] args) throws IOException {
        MyReader reader = new MyReader();
        String s = reader.readString();
        System.out.println(problem063b(s));
    }

    private static String problem063b(String s) {
        List<Character> charList = new ArrayList<>();
        for (char c : s.toCharArray()) {
            if (charList.contains(c)) return "no";
            charList.add(c);
        }
        return "yes";
    }

    private static class MyReader {
        private final BufferedReader br;
        private MyReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String readString() throws IOException {
            return br.readLine();
        }

        private int readInt() throws IOException {
            return Integer.parseInt(readString());
        }

        private String[] readStrings(String regex) throws IOException {
            return readString().split(regex);
        }

        private int[] readInts(String regex) throws IOException {
            String[] strings = readStrings(regex);
            int[] ints = new int[strings.length];
            for (int i = 0; i < ints.length; i++) {
                ints[i] = Integer.parseInt(strings[i]);
            }
            return ints;
        }
    }
}

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

#define Bye return 0
#define ll long long

using namespace std;

void solve(){
    int n; cin>>n;

    map<string, int> str;
    for(int i=0; i<n; i++){
        string e; cin>>e;
        str[e]++;
    }
    
    int max_value = INT_MIN;
    string ans;
    for (auto item : str)
        if(item.second>max_value)
            max_value = item.second;
    
    for (auto item : str)
        if(item.second == max_value)
            cout<<item.first<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 19152
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int a[5005];
ll p[5005];
bool vis[5005];
int tot=0;
vector<int>vec[5005];
map<int,ll>mp;
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>p[i];
    for(int i=1;i<=n;i++)
    {
        if(vis[i]) continue;
        tot++;
        int t=i;
        ll ans=0;
        while(vis[t]==0)
        {
            vis[t]=1;
            vec[tot].push_back(t);
            ans+=p[t];
            t=a[t];
        }
        mp[tot]=ans;
    }
//    for(int i=1;i<=tot;i++)
//    {
//        printf("val=%lld :",mp[i]);
//        for(auto  it:vec[i]) printf("%d ",it);
//        puts("");
//    }


    ll res=p[1];
    for(int i=1;i<=tot;i++)
    {
        for(int j=0;j<(int)vec[i].size();j++)
        {
            int t=vec[i][j];
            int step=0;
            ll ans=0;
            do
            {
                step++;
                t=a[t];
                ans+=p[t];
                if(mp[i]>0)
                {
                    res=max(res,ans+mp[i]*((k-step)/(int)vec[i].size()));
                }
               // printf("%+lld\n",ans);
                res=max(res,ans);
            }while(t!=vec[i][j]&&step<k);
        }
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 3860
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def get_yakusu(n):
    ans = set()
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            if i != 1:
                ans.add(i)
            if n // i != i:
                ans.add(n // i)
    return ans

def main():
    N = I()
    cnt = 0
    if N == 2:
        print(1)
        return
    yakusu = get_yakusu(N)
    n1yakusu = get_yakusu(N-1)
    for n in yakusu:
        cpN = N
        while True:
            if n == 1:
                break
            if cpN % n == 0:
                cpN = cpN // n
            else:
                break
        if cpN % n == 1:
            cnt += 1
    cnt += len(n1yakusu)
    print(cnt)
main()



Measured memory_bytes: 65516
#include<bits/stdc++.h>
using namespace std;
vector<int> solve(vector<int> v, int n, int index){
  vector<int> rtn;
  map<int, int> temp;
  for(int i = index; i < n; i += 2){
    temp[v[i]]++;
  }
  int maxx = 0;
  int num;
  int sec = 0;
  for(auto a: temp){
    if(a.second > maxx){
      if(sec != 0 && maxx > sec) sec = maxx;
      maxx = a.second;
      num = a.first;
      continue;
    }
    if(a.second > sec && a.second <= maxx){
      sec = a.second;
    }
  }
  rtn.push_back(num);
  rtn.push_back(maxx);
  rtn.push_back(sec);
  return rtn;
}
int main(){
  int n; cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  vector<int> ansA = solve(v, n, 0);
  vector<int> ansB = solve(v, n, 1);
  if(ansA[0] != ansB[0]) cout << n - ansA[1] - ansB[1] << endl;
  else cout << min(n - ansA[1] - ansB[2], n - ansA[2] - ansB[1]) << endl; 
}

Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  int n, m;
  cin >> n >> m;
  map<int, priority_queue<pii, vector<pii>, greater<pii> > > data;
  rep(i, m) {
    int p, y;
    cin >> p >> y;
    (data[p]).push(make_pair(y, i));
  }
  vector<string> ans(m);
  for (auto& x : data) {
    int p = x.first;
    // cout << p << endl;
    priority_queue<pii, vector<pii>, greater<pii> > q = x.second;
    int cnt = 0;
    while (!q.empty()) {
      pii x = q.top();
      int i = x.second;
      q.pop();
      stringstream ss;
      ss << setw(6) << setfill('0') << p;
      ss << setw(6) << setfill('0') << cnt + 1;
      ans[i] = ss.str();
      cnt++;
    }
  }
  rep(i, m) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 14720
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.size();
  int X, Y;
  cin >> X >> Y;

  vector<int> FX;
  vector<int> FY;
  int turn = 0;
  int step = 0;
  rep(i, N + 1) {
    if (S[i] == 'F') {
      ++step;
    } else {
      if (turn == 0)
        FX.emplace_back(step);
      else
        FY.emplace_back(step);
      turn = (turn == 1) ? 0 : 1;
      step = 0;
    }
  }

  int FXN = FX.size();
  vector<vector<bool>> DPX(FXN + 1, vector<bool>(16002, false));
  DPX[0][8000] = true;
  rep(i, FXN) {
    rep(j, 16002) {
      if (!DPX[i][j]) continue;
      if (j + FX[i] < 16002) DPX[i + 1][j + FX[i]] = true;
      if (i == 0) continue;
      if (0 <= j - FX[i]) DPX[i + 1][j - FX[i]] = true;
    }
  }

  int FYN = FY.size();
  vector<vector<bool>> DPY(FYN + 1, vector<bool>(16002, false));
  DPY[0][8000] = true;
  rep(i, FYN) {
    rep(j, 16002) {
      if (!DPY[i][j]) continue;
      if (j + FY[i] < 16002) DPY[i + 1][j + FY[i]] = true;
      if (0 <= j - FY[i]) DPY[i + 1][j - FY[i]] = true;
    }
  }

  if (DPX[FXN][X + 8000] && DPY[FYN][Y + 8000]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 19156
#include<iostream>
#include<string>
#include<vector>
#include<stack>
using namespace std;

vector<int> G[1001];
vector<int> depth[1001];

int depmax=0;

void dfs(){
    stack<pair<int, int> > sta;
    sta.push(make_pair(1,1));
    while(!sta.empty()){
        pair<int, int> p=sta.top();
        sta.pop();
        int v = p.first;
        int d = p.second;
        depth[d].push_back(v);
        depmax=max(depmax,d);
        for(int i=0; i<G[v].size(); i++){
            sta.push(make_pair(G[v][i],d+1));
        }
    }
}

int main(){
    //input
    int N;
    cin >> N;
    int P;
    int i,j,k,l;
    for(i=2; i<=N; i++){
        cin >> P;
        G[P].push_back(i);
    }
    int X[N+1];
    for(i=1; i<=N; i++){
        cin >> X[i];
    }

    //calc
    dfs();
    int sum[N+1][2];
    string st[2][5001];
    int root,child;
    bool posi=1;
    int Y;
    string sen;
    for(k=1; k<=N; k++){
        if(G[k].size()==0){
            sum[k][0]=0;
            sum[k][1]=X[k];
        }
    }
    for(i=depmax-1; i>=1; i--){
        for(j=0; j<depth[i].size(); j++){
            root=depth[i][j];
            if(G[root].size()==0) continue;
            for(l=0; l<=5000; l++){
                st[0][l]=".";
                st[1][l]=".";
            }
            st[0][0]="";
            for(k=0; k<G[root].size(); k++){
                child=G[root][k];
                for(l=0; l<=X[root]; l++){
                    if((st[(k%2)][l]!=".")&&(st[(k%2)][l].size()==k)){
                        if(l+sum[child][0]<=X[root]){
                            st[!(k%2)][l+sum[child][0]]=st[(k%2)][l]+'0';
                        }
                        if(l+sum[child][1]<=X[root]){
                            st[!(k%2)][l+sum[child][1]]=st[(k%2)][l]+'1';
                        }
                    }
                }
            }
            for(l=X[root]; l>=0; l--){
                if((st[(G[root].size())%2][l]!=".")&&(st[(G[root].size())%2][l].size()==G[root].size())) break;
            }
            if(l>=0){
                sen=st[(G[root].size())%2][l];
                Y=0;
                for(k=0; k<G[root].size(); k++){
                    child=G[root][k];
                    if(sen[k]=='0'){
                        Y += sum[child][1];
                    }else{
                        Y += sum[child][0];
                    }
                }
                sum[root][0]=X[root];
                sum[root][1]=Y;
            }else{
                posi=0;
                break;
            }
        }
        if(posi==0) break;
    }

    //answer
    if(posi==1){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 4360
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {

	var i int
	sc.Split(bufio.ScanWords)

	n := nextInt()
	k := nextInt()
	h := make([]int, n)
	for i = 0; i < n; i++ {
		h[i] = nextInt()
	}

	var c int
	for _, hi := range h {
		if hi >= k {
			c++
		}
	}

	fmt.Println(c)
}


Measured memory_bytes: 1792
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

int main()
{
    string S;
    cin >> S;
    bool YYMM = false;
    bool MMYY = false;

    string front;
    front.push_back(S[0]);
    front.push_back(S[1]);
    string end;
    end.push_back(S[2]);
    end.push_back(S[3]);

    // MMYY
    if ( front >=  "01" and front <= "12")
    {
        
        MMYY = true;
    }
    // YYMM
    if ( end >= "01" and end <= "12")
    {
        YYMM = true;
    }

    if (YYMM and MMYY)
        cout << "AMBIGUOUS" << endl;
    else if (YYMM)
        cout << "YYMM" << endl;
    else if (MMYY)
        cout << "MMYY" << endl;
    else 
        cout << "NA" << endl;
}

Measured memory_bytes: 384
N, K = map(int, input().split())
d = []
A = []
hasSnack = []
allSunuke = [i for i in range(1, N+1)]

for i in range(K):
	d.append(int(input()))
	InputA = list(map(int, input().split()))
	A.append(InputA)

	hasSnack += InputA

print(len(list(set(allSunuke) - set(hasSnack))))

Measured memory_bytes: 9380
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define INF 1<<29
#define MAX 
using namespace std;

void solve(){
 int n,m,d;
 string s;
 for(;;){
  cin>>n;
  if(!n) break;
  cin>>m;
  cin>>s;
  s+=s[m-1];
  m++;
  int l=0;
  bool IOI=false;
  int cnt=0;
  FOR(r,m){
   if(IOI){
    if(s[r]!=s[r-1]) continue;
    else{
     if(s[r]=='O'){
      d=(r-l-2)/2-n+1;
      IOI=false;
     }
     else d=(r-l-1)/2-n+1;
     if(d>0) cnt+=d;
     l=r;
    }
   }
   else{
    if(s[r]=='O'){
    }
    else{
     IOI=true;
     l=r;
    }
   }
  }
  cout<<cnt<<endl;
 }
}

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

Measured memory_bytes: 2104
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int n,a[100010];
map<int,int> m;
int main()
{
    scanf("%d",&n);int k;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&k);
        a[i]=k;
        m[k]++;
    }
    sort(a,a+n);int flag=0;long long sum=1;bool mm=false;
    for(int i=n-1;i>=0;i--)
    {
        if(m[a[i]]>=2)
        {
            sum*=a[i];
            flag++;
            m[a[i]]-=2;
            if(flag==2) {mm=true;printf("%lld\n",sum);break;}
        }
    }
   if(!mm) printf("0\n");
return 0;
}


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

using namespace std;

int main(){
int aa,bb;
vector<int> a;
vector<int> b;
cin>>aa;
for(int i=0;i<aa;i++){
int aaa,bbb;
cin>>aaa>>bbb;
a.push_back(aaa*60+bbb);
}
cin>>bb;
for(int i=0;i<bb;i++){
int aaa,bbb;
cin>>aaa>>bbb;
a.push_back(aaa*60+bbb);
}
sort(a.begin(),a.end());
a.erase(unique(a.begin(), a.end()), a.end());
for (int i = 0; i < a.size()-1; ++i) {
	//cout<<a[i]/60<<":"<<((a[i]%60>=10)?(a[i]%60):(cout<<"0"<<a[i]%60))<<" ";
	printf("%d:%02d ",a[i]/60,a[i]%60);
}
printf("%d:%02d\n",a.back()/60,a.back()%60);
return 0;
}

Measured memory_bytes: 3272
#ifdef lolipop
#define _GLIBCXX_DEBUG
#endif

/*
    This ain't a milly rock
    This a money dance
    And my D' ain't hard
    That's a .30 in my pants
*/

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <ctime>
#include <map>
#include <random>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ld long double

using namespace std;

// mt19937 rnd(time(nullptr));

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

const ld pii = 3.1415926535897932384626433832;

void solve() {
    ld a, b;
    cin >> a >> b;
    ld h, m;
    cin >> h >> m;
    ld x1 = cos((pii / 6.0) * (h + (m / 60.0)) ) * a;
    ld y1 = sin((pii / 6.0) * (h + (m / 60.0)) )  * a;
    ld x2 = cos((pii / 30.0) * m) * b;
    ld y2 = sin( (pii / 30.0) * m) * b;
    cout << fixed << setprecision(20) << sqrt( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) );
}

/*const int MOD = 1000000007LL;

int pwr(int x, int n) {
    if (n == 0) return 1;
    if (n == 1) return x;
    int xx = pwr(x, n / 2);
    xx = (xx * xx) % MOD;
    if (n % 2 == 0) {
        return xx;
    } else {
        return (x * xx) % MOD;
    }
}

int inv(int x) {
    return pwr(x, MOD - 2);
}

void solve() {
    int n;
    cin >> n;
    vector <int> v(n);
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        a %= MOD;
        b %= MOD;
        v[i] = (a * b) % MOD;
    }
    int ans = pwr(2, n);
    map <int,int> cnt;
    for (int i = 0; i < n; ++i) {
        int x = cnt[v[i]];
        int m1 = ((pwr(2, x) - 1 + MOD) % MOD);
        int m2 = pwr(2, i - x);
        ans = (ans - (m1 * m2) % MOD + MOD) % MOD;
        cnt[-v[i]]++;
    }
    cout << ans << '\n';
}*/

signed main() {
#ifdef lolipop
    freopen("input.txt", "r", stdin);
#else
    fastio();
#endif

    int T = 1;
//    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3616
class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y: return False
        if self.parents[x] > self.parents[y]: x,y = y,x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return True
    
    # 根が同じか？
    def same(self, x , y):
        return self.find(x) == self.find(y)

    # 属するUnionの要素数
    def size(self, x):
        return -self.parents[self.find(x)]

n,m,k = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(m)]
cd = [list(map(int,input().split())) for _ in range(k)]

# 初期化
uf = UnionFind(n)
# くっつける
for a,b in ab: uf.unite(a-1,b-1)

# 自身を引く(-1)
ans = [uf.size(i)-1 for i in range(n)]

for a,b in ab:
    if uf.same(a-1,b-1):
        ans[a-1] -= 1
        ans[b-1] -= 1
for c,d in cd:
    if uf.same(c-1,d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print(*ans)

Measured memory_bytes: 62116
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  ll ans = 0;
  ll h_max = 0;
  REP(i, N){
    ll H;
    cin >> H;
    if(h_max<=H){
      h_max = H;
      ans++;
    }
  }
  cout << ans << "\n";

  return 0;
}

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

const int B = 1000;
const int maxn = 100050;
const int maxm = 5050;

int main() {
    int n;
    std::stack<int> s;
    std::cin >> n;
    while(n--) {
        int x;
        std::cin >> x;
        if(x % 2 == 0)
            s.push(x);
    }
    bool flag = true;
    while(!s.empty()) {
        int x = s.top();
        s.pop();
        if(x % 3 != 0 and x % 5 != 0) {
            flag = false;
            break;
        }
    }
    if(flag)
        std::cout << "APPROVED";
    else
        std::cout << "DENIED";
}


Measured memory_bytes: 256
r1, c1, r2, c2 = list(map(int, input().split()))

MOD = 10 ** 9 + 7


def modInverse(x, p):
    # Fermat's little theorem
    return pow(x, p - 2, p)


def nCr(n, r, p):
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return num * modInverse(den, p) % p


def hockey(n, m):
    # sum i=0 to m of nCr(n + i, i) == nCr(n + m + 1, m)
    return nCr(n + m + 1, m, MOD)


tot1 = hockey(c2, r2 + 1) - hockey(c2, r1)
tot2 = hockey(c1 - 1, r2 + 1) - hockey(c1 - 1, r1)
print((tot1 - tot2) % MOD)


Measured memory_bytes: 3188
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();

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

		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += Math.min(x[i], Math.abs(k - x[i]));
		}

		pr.println(ans * 2);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 22736
import java.util.*;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a%b==0) {
			System.out.println(a/b*c);
		}else {
			System.out.println((a/b+1)*c);
		}

	}


}


Measured memory_bytes: 35700