akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n = sc.nextInt();


        long n=sc.nextLong()-1;
        long d[] = sc.nextLongArray(5);
        sort(d);
        
    
       
        out.println(n/d[0]+5);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id,T;
//    P(int id, int T) {
//        this.id=id;
//        this.T=T;
//    }
//    public int compareTo(P p){
//        return id-p.id; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

int main(){
	
	string X;
	getline(cin,X);
	string ans = X;
  
  string apple = "apple";
  string peach = "peach";
  while(1){
	  int x=X.find(apple,0);
	   if ( x == string::npos ) break;
    for ( int i = 0; i < 5; i++ ) {
      ans[x+i] = peach[i];
      X[x+i] = '-';
    }
  
  }
  while(1){
	  int x=X.find(peach,0);
	   if ( x == string::npos ) break;
    for ( int i = 0; i < 5; i++ ) {
      ans[x+i] = apple[i];
      X[x+i] = '-';
    }
  
  }
  cout<<ans<<endl;
  return 0;
}
	
	
	
	

Measured memory_bytes: 1184
x, n = map(int, input().split())
p = list(map(int, input().split()))
n = list(i for i in range(-1, 110) if i not in p)

diff = 110
ans = 0

for i in n:
    if diff > abs(x-i):
        diff = abs(x-i)
        ans = i
        
print(ans)

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

int main(){

  int N;
  bool ans = false;
  cin >> N;
  char S[N];
  for(int i=0; i<N; i++){
    cin >> S[i];
    if(S[i]=='Y') ans = true;
  }

  if(ans){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }

  return 0;
}


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

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

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

  vector<int> b;
  b.reserve(n);
  if (n % 2 == 0) {
    for (int i = n - 1; i >= 1; i -= 2) {
      b.emplace_back(a[i]);
    }
    for (int i = 0; i < n; i += 2) {
      b.emplace_back(a[i]);
    }
  } else {
    for (int i = n - 1; i >= 0; i -= 2) {
      b.emplace_back(a[i]);
    }
    for (int i = 1; i < n; i += 2) {
      b.emplace_back(a[i]);
    }
  }

  cout << b[0];
  for (int i = 1; i < n; ++i) {
    cout << ' ' << b[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3840
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB emplace_back
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int,int>;
using pll = pair<ll,ll>;

constexpr int IN = 2*10e5+5;
constexpr int INF = 1e9+5;
constexpr int INI = -1;

ll n, q, a[IN], dp[IN], val[IN], x, y;
vll adj[IN];

ll dfs(int V, int pV)
{
    for(auto v:adj[V])
    {
        if(v==pV) continue;
        dp[v] += dp[V];
        dfs(v, V);
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> q;
    for(int i=1; i<n; ++i)
    {
        cin >> x >> y;
        adj[x].PB(y);
        adj[y].PB(x);
    }
    for(int i=1; i<=q; ++i)
    {
        cin >> x >> y;
        dp[x] += y;
    }
    dfs(1,0);
    for(int i=1; i<=n; ++i)
        cout << dp[i] << endl;
    return 0;
}


Measured memory_bytes: 65408
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
import math

a, b, h, m = map(int, input().split())
deg_h = (h * 120 + m * 2) % 1440
deg_m = (m * 24) % 1440
diff = (deg_h - deg_m) % 1440
if deg_h >= deg_m:
    diff = deg_h - deg_m
else:
    diff = deg_m - deg_h
if 1440 - diff < diff:
    diff = 1440 - diff
c_sqr = a*a + b*b - 2.0 * a * b * math.cos(diff / 1440 * math.pi * 2)
print(math.sqrt(c_sqr))

Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    vector <int> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    long long int n, a, b, c, d, k, i, j, ng=0, ok=0;
    scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
    char s[n+1];
    a--;
    b--;
    c--;
    d--;
    scanf("%s", s);
    if(c<d) ok=1;
    for(i=a; i<=c||i<=d; i++){
        if(i>0){
            if(s[i-1]=='#'&&s[i]=='#') ng=1;
        }
        if(c>d && i>=b+1 && i<=d+1){
            if(s[i-2]=='.'&&s[i-1]=='.'&&s[i]=='.') ok=1;
        }
    }
//    printf("%lld %lld", ok, ng);
    if(ok==1&&ng==0) printf("Yes");
    else printf("No");
    
}

Measured memory_bytes: 384
#include <iostream>
#include <complex>
#include <limits.h>

int solution1(int h, int w)
{
	int firstLine = h / 3, secondLine = (h + firstLine) / 2;

	int s1 = firstLine * w, s2 = (secondLine - firstLine) * w, s3 = (h - secondLine) * w;
	int max = 0;

	if (abs(s1 - s2) > max)
		max = abs(s1 - s2);

	if (abs(s2 - s3) > max)
		max = abs(s2 - s3);

	if (abs(s1 - s3) > max)
		max = abs(s1 - s3);

	return max;

}

int solution2(int h, int w)
{
	int horizontalLine;

	if (h % 3 == 2)
		horizontalLine = (h / 3) + 1;
	else
		horizontalLine = h / 3;

	int s1 = horizontalLine * w;

	int verticalLine = w / 2;

	int s3, max = 0;

	int s2 = (w - verticalLine) * (h - horizontalLine);

	if (w * 2 == verticalLine)
		s3 = (w - verticalLine) * (h - horizontalLine);
	else
	{
		s3 = (w - (w - verticalLine)) * (h - horizontalLine);
	}

	if (abs(s1 - s2) > max)
		max = abs(s1 - s2);

	if (abs(s2 - s3) > max)
		max = abs(s2 - s3);

	if (abs(s1 - s3) > max)
		max = abs(s1 - s3);

	return max;
}

int main()
{
	int h, w;
	std::cin >> h >> w;

	int max = INT_MAX;

	if (!solution1(h, w))
	{
		std::cout << 0;
		return 0;
	}
	else if (solution1(h, w) < max)
		max = (solution1(h, w));

	if (!solution1(w, h))
	{
		std::cout << 0;
		return 0;
	}
	else if (solution1(w, h) < max)
		max = (solution1(w, h));



	if (!solution2(h, w))
	{
		std::cout << 0;
		return 0;
	}
	else if (solution2(h, w) < max)
		max = (solution2(h, w));

	if (!solution2(w, h))
	{
		std::cout << 0;
		return 0;
	}
	else if (solution2(w, h) < max)
		max = (solution2(w, h));

	std::cout << max;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	cin >> n;
	long long sum = 0;
	long long sum_plus_y0 = 0;
	long long a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
		if (i%2 == 0)
			sum_plus_y0 += a[i];
	}
	long long y[n];
	y[0] = 2*sum_plus_y0 - sum;
	for (int i = 1; i < n; i++) {
		y[i] = 2 * a[i-1] - y[i-1];
	}
	for (int i = 0; i < n; i++) {
		printf("%lld", y[i]);
		if (i < n-1)
			putchar(' ');
		else
			putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 5224
def spaceinput():
    return list(map(int,input().split(" ")))


N,M=spaceinput()

S=[]
for i in range(M):
    tmp=spaceinput()
    k=tmp[0]
    S.append(tmp[1:])

p=spaceinput()

res=0
for i in range(2**N):
    flg=False
    hoge=list(bin(i)[2:].zfill(N))
    state_sw=list(map(int,hoge))
    sp=[0]*M
    #print(state_sw)
    for j in range(M):        
        for l in S[j]:
            if state_sw[l-1]:
                sp[j]+=1
        if sp[j]%2 !=p[j]:
            flg=True
            break
    #print("sp",sp)
    if flg:
        continue        
    res+=1

print(res)


Measured memory_bytes: 3064
N = int(input())
A = [int(a) for a in input().split()]

p = 1000000007

num = [0] * N + [3]  # num[-1] returns 3
tot = 1
for i in range(N):
    tot = tot * (num[A[i] - 1] - num[A[i]]) % p
    num[A[i]] += 1

print(tot)


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

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

fn main() {
    let n:usize = read();
    let mut v:Vec<usize> = (0..n).map(|_| read()).collect();
    v.sort_by(|a, b| b.cmp(a));
    let mut ans = 0;
    for i in 0..n {
        if i % 2 == 0 {
            ans += v[i];
        } else {
            ans -= v[i];
        }
    }
    println!("{}", ans);
}


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

string maps[110];

int h, w;

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

void dfs(int x, int y) {
    char type = maps[x][y];
    maps[x][y] = '.';
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (nx >= 0 && nx < h && ny >= 0 && ny < w && maps[nx][ny] == type) {
            dfs(nx, ny);
        }
    }
}

int main() {
    while (true) {
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        for (int i = 0; i < h; i++) {
            cin >> maps[i];
        }
        int count = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (maps[i][j] != '.') {
                    count++;
                    dfs(i, j);
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}

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

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

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int a[3];
bool f[101] = {false};

int main(){
  REP(i,3) cin >> a[i];
  REP(i,3) f[a[i]] = true;
  int cnt = 0;
  REP(i,101){
    if(f[i]) cnt++;
  }
  cout << cnt <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }

int main(){
    ll n;
    in(n);
    if(n%2==1||n<2){
        out(0);
        return 0;
    }
    n/=2;
    ll ans=0,d=5;
    for(int i=0;d<=n;i++){
        ans+=n/d;
        d*=5;
    }
    out(ans);
}

Measured memory_bytes: 3768
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

const int MAXN = 100100;
int dp[MAXN];

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

    rep(i, MAXN) dp[i] = INF; 
    dp[0] = 0;

    rep(n, MAXN) {
        for (int i = 1; i <= n; i *= 6) {
            dp[n] = min(dp[n], dp[n-i] + 1);
        }
        for (int i = 1; i <= n; i *= 9) {
            dp[n] = min(dp[n], dp[n-i] + 1);
        }
    }
    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    string S;
    cin >> S;
    ll ans = 1;
    map<char, ll> m;
    for (int i = 0; i < N; i++)
    {
        if (m.find(S[i]) == m.end())
        {
            m[S[i]] = 1;
        }else{
            m[S[i]]++;
        }
    }

    for (auto &&i : m)
    {
        ans = mulMod(ans, i.second + 1);
    }

    cout << ans - 1 << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define int long long
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repr(i, a, b) for(int i = a - 1; i >= b; i--)
#define iter(m) for(auto it = m.begin(); it != m.end(); it++)
#define iterr(m) for(auto it = m.rbegin(); it != m.rend(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
signed main(){
    speed;
    int h, w, m; cin >> h >> w >> m;
    map<int, int> row, column;
    map<pair<int,int>, int> p;
    while(m--) {
        int x, y; cin >> x >> y;
        row[x]++;
        column[y]++;
        p[{x, y}]++;
       
    }
    int mx_r = 0;
    int r = column.begin()->first;
    int ans = 0;
    iter(row) {
        if(it->second > mx_r) {
            mx_r = it->second;
            r = it->first;
        }
    }
    for(int i = 0; i <= w; i++) {
        ans = max(ans, mx_r + column[i] - p[{r, i}]);
    }
    int mx_c = 0;
    int c = 0;
    iter(column) {
        if(it->second > mx_c) {
            mx_c = it->second;
            c = it->first;
        }
    }
    for(int i = 0; i <= h; i++) {
        ans = max(ans, mx_c + row[i] - p[{i, c}]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 97360
#include <stdio.h>

int main()
{   char b[2];
    scanf("%c",&b[0]);
    if(b[0]=='A')
    printf("T");
    if(b[0]=='T')
    printf("A");
    if(b[0]=='G')
    printf("C");
    if(b[0]=='C')
    printf("G");

    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

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

	string s;
	cin >> s;

	int ans = accumulate(begin(s), end(s), 700, [](int res, char c) {
		return res + (c == 'o' ? 100 : 0);
	});

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


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







int main(void) {

	bool safe = true;

	int n, m, k;

	cin >> n >> m;

	char grid[n][m];

	char c;

	unordered_map<char, int> mp;

	set<char> s;

	for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin >> c, ++mp[c], s.insert(c);

	for (int i = 0; i < n / 2; ++i)
		for (int j = 0; j < m / 2; ++j) {

			bool ok = false;

			for (auto c : s) {

				if (mp[c] >= 4) {

					mp[c] -= 4;

					ok = true;

					break;
				}
			}

			if (!ok) safe = false;

		}

	if ((n & 1) || (m & 1)){

		int even=0,odd=0;
		
		for(auto c:s){
			if(mp[c]>0){
				if(mp[c]&1) even+=mp[c]-1,odd+=1;
				else even+=mp[c]-1;
			}
		}

		if(odd>1) safe=0;
		

	}

		if (safe) cout << "Yes";
		else cout << "No";











	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 101010;
int main(){
	int a,b;
	cin>>a>>b;
	if(((a%10)*(b%10))%2==1)cout<<"Odd";
	else cout<<"Even";
	return 0;
}  

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

int main()
{
    int n;
    while(cin>>n){
        int room[4][3][10]={0};
        for(int i=0;i<n;i++){
          int b,f,r,v;
          cin>>b>>f>>r>>v;
          room[b-1][f-1][r-1]+=v;
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<3;j++){
                for(int k=0;k<10;k++){
                    cout<<" "<<room[i][j][k];
                }
                cout<<endl;
            }
            if(i!=3)
                cout<<"####################"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int n,k;
  cin >> n >> k;
  ll ans=k*pow(k-1, n-1);

  cout << (n==1 ? k : ans) << endl;
  return 0;
} 

Measured memory_bytes: 3992
#include <iostream>
#include <string>

using namespace std;

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


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

       }

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


    return 0;
}


Measured memory_bytes: 256
x, n = map(int,input().split())
p = list(map(int,input().split()))
y = 0
z = 0
while y == 0:
    a = x + z
    b = x - z
    if a in p and b in p:
        z += 1
    elif a not in p and b in p:
        print(a)
        y = 4
    elif b not in p:
        print(b)
        y = 5

Measured memory_bytes: 8920
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int[] l=new int[n];
        int sum=0,max=0;
        for (int i = 0; i < n; i++) {
            l[i]=sc.nextInt();
            max=max(max,l[i]);
            sum+=l[i];
        }
        sum-=max;
        if(sum>max){
            out.println("Yes");
        }else out.println("No");
    }
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    vector<lint> a(n);
    rep(i, n){
        cin >> a[i];
    }

    vector<lint> sum(n + 1);
    REP(i, 1, n + 1){
        sum[i] = sum[i - 1] + a[i - 1];
    }

    unordered_map<lint, lint> mp;
    lint ans = 0;
    rep(i, n + 1){
        ans += mp[sum[i]];
        ++mp[sum[i]];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11592
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define itn int
#define all(c) c.begin(),c.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;

const ll N = 1e6 + 5, inf = 1e18, mod = 1e9 + 7;
const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31,30, 31, 31, 30, 31, 30, 31};

template<typename T>
ostream& operator<< (ostream& out, const vector<T>& mas) {
    for (const auto& x : mas) {
        out << x << ' ';
    }
    out << '\n';
    return out;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

inline ll getPow(ll a, ll b) {
    ll res = 1ll, tp = a;
    while (b){
        if (b&1ll) {
            res *= tp;
        }
        tp *= tp;
     //   tp %= mod; res %= mod;
        b >>= 1ll;
    }
    return res;
}

ll vec_mult(const pll & t1, const pll & t2, const pll & t3) {
    const ll & x1 = t1.first, y1 = t1.second;
    const ll & x2 = t2.first, y2 = t2.second;
    const ll & x3 = t3.first, y3 = t3.second;
    return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1));
}

void ok() {
    cout << "YES" << '\n';
}

void no() {
    cout << "NO" << '\n';
}

inline ll nxt() {
    ll x;
    cin >> x;
    return x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    ll n = nxt() - 1;
    cout << (1 + n) * n / 2;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

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

    map<string, int> judgeToCntMap;
    judgeToCntMap["AC"] = 0;
    judgeToCntMap["WA"] = 0;
    judgeToCntMap["TLE"] = 0;
    judgeToCntMap["RE"] = 0;

    for (int i = 0; i < n; i++)
    {
        string tmp;
        cin >> tmp;
        judgeToCntMap[tmp]++;
    }

    cout << "AC" << " x " << judgeToCntMap["AC"] << endl;
    cout << "WA" << " x " << judgeToCntMap["WA"] << endl;
    cout << "TLE" << " x " << judgeToCntMap["TLE"] << endl;
    cout << "RE" << " x " << judgeToCntMap["RE"] << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());
 
    int ans = 0;
 
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
int main(){
    int N;
    cin >> N;
 
    for(int i = 0; i < 3; i++){
        if(N%10 == 7){
            cout << "Yes" << endl;
            return 0;
        }
        N /= 10;
    }
 
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include <math.h> 
using namespace std;

int main()
{
	int a,b,k,i;
	cin>>a>>b>>k;
	vector<int> ans;
	if (a > b)
	{
		for(i=b; i>0; i--)
		{
			if ((a%i == 0) && (b%i==0))
			{
				ans.push_back(i);
			}
			
		}
	}
	else
	{
		for(i=a; i>0; i--)
		{
			if ((a%i == 0) && (b%i==0))
			{
				ans.push_back(i);
			}
			
		}
	}
	cout<<ans[k-1];
}

Measured memory_bytes: 256
# ABC168D
# https://atcoder.jp/contests/abc168/tasks/abc168_d

n,m=map(int, input().split())
ab=[[]for _ in range(n)]
for i in range(m):
    a,b = list(map(int, input().split()))
    a,b = a-1, b-1
    ab[a].append(b)
    ab[b].append(a)
    '''
    まず両方を追加する考えがなかった。
    浅い部屋からも深い部屋からも参照できる。
    その代わりに visitedで考えなくて良い部屋を記録している。
    部屋１につながっているのはもっとも浅い部屋でそこから考えることがきっかけになる？
    '''
#print(ab)
ans = [0]*n
visited={0}
stack=[0]
for i in stack:
    '''
    現在考えている部屋を stack、そこにつながる部屋 ab[i]として考える。
    stack=[0]なので1の部屋から始める。なので深さ1の部屋が ab[i](ab[0])で分かる。
    i==0の始めの一周では、ab[i]は深さ１の部屋のリストであり、それぞれの部屋を jとして順番に考える。
    (このように深さ1から考えられる＋次に深さ2の部屋を求めるというのが上手くいく)
    その現在考えている部屋 i(stackの循環)とそこにつながる部屋 j(abの循環)なので、
    部屋 jはより浅い部屋 iを道しるべにすればよい。
    しかし、ab[a], ab[b]と両方を追加しているので、浅い部屋も深い部屋も abには含まれている。
    浅い部屋から順に考えているので、過去に調べた abの値は無視するために visitedを導入する。たぶん。
    '''
    for j in ab[i]:
        #print(i,j,'----------------------')
        if j in visited:
            continue
        stack.append(j)
        visited.add(j)
        ans[j]=i+1
        #print('stack', stack)
        #print('visited', visited)
        #print('ans', ans)
check=0
for i in ans[1:]:
    if i==0:check==1
if check:
    print('No')
else:
    print("Yes")
    print(*ans[1:])


Measured memory_bytes: 42952
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int a,b,c,ans=0,tmp_a,tmp_b,tmp_c;
  	cin >> a >> b >> c;
    if(a==b&&a==c&&!(a%2)){
        cout << -1 << endl;
        return 0;
    }
    while((!(a%2))&&(!(b%2))&&(!(c%2))){
        ans++;
        tmp_a=a/2;
        tmp_b=b/2;
        tmp_c=c/2;
        a=tmp_b+tmp_c;
        b=tmp_a+tmp_c;
        c=tmp_a+tmp_b;
    }
    cout << ans << endl;
}


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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> correct(N,0);
  vector<int> wrong(N,0);
  
  int p;
  string str;
  for(int i=0;i<M;i++){
    cin>>p>>str;
    if(correct.at(p-1)==0){
      if(str=="AC"){
        correct.at(p-1)=1;
      }else{
        wrong.at(p-1)++;
      }
    }
  }
  int c=0,w=0;
  for(int i=0;i<N;i++){
    c+=correct.at(i);
    if(correct.at(i)==1){
      w+=wrong.at(i);
    }
  }
  cout<<c<<" "<<w<<endl;
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

const long long MAX = 2e5+100;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll n;
vector<vector<ll>> g;
P dp[MAX];

P ide(){
    return P(0, 1);
}

P f1(P a, P b){
    return P(a.first+b.first, (a.second*b.second%MOD)*COM(a.first+b.first, b.first)%MOD);
}

P f2(P a){
    return P(a.first+1, a.second);
}

void dfs1(ll at, ll from = -1){
    dp[at] = ide();
    zep(i, 0, g[at].size()){
        ll nx = g[at][i];
        if(nx != from){
            dfs1(nx, at);
            dp[at] = f1(dp[at], f2(dp[nx]));
        }
    }
}

void dfs2(ll at, ll from = -1, P x = P(0, 1)){
    //cout << at << " " << x.first << " " << x.second << endl;
    dp[at] = f2(f1(dp[at], x));

    ll m = g[at].size();
    P l[m], r[m];
    zep(i, 0, m){l[i] = r[i] = (g[at][i] == from)? x : f2(dp[g[at][i]]);}
    //zep(i, 0, m){cout << l[i].first << " ";}cout << "p" << endl;
    //zep(i, 0, m){cout << l[i].second << " ";}cout << "p" << endl;
    rep(i, 1, m-1){l[i] = f1(l[i], l[i-1]);}
    rrep(i, m-2, 0){r[i] = f1(r[i], r[i+1]);}

    zep(i, 0, m){
        ll nx = g[at][i];
        if(nx != from){
            P tmp = ide();
            if(i > 0){tmp = f1(tmp, l[i-1]);}
            if(i < m-1){tmp = f1(tmp, r[i+1]);}
            //cout << "l " << l[i].first << " " << l[i].second << endl;
            //cout << "r " << r[i+1].first << " " << r[i+1].second << endl;
            //cout << f2(f1(l[i], r[i+1])).first << f2(f1(l[i], r[i+1])).second << endl;
            dfs2(nx, at, f2(tmp));
        }
    }
}

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

    cin >> n;
    g.resize(n);
    zep(i, 0, n-1){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs1(0);
    //zep(i, 0, n){cout << dp[i].first << dp[i].second << endl;}
    
    dfs2(0);
    //zep(i, 0, n){cout << dp[i].first << dp[i].second << endl;}
    zep(i, 0, n){print(dp[i].second)}

    return 0;
}

Measured memory_bytes: 28784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  const int MOD = 1000000007;

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

  vector<long long> p(N);
  vector<long long> n(N);
  int Po = 0;
  int Ne = 0;
  bool has_zero = false;
  rep(i, N)
  {
    int tmp;
    cin >> tmp;
    if (tmp < 0)
    {
      n[Ne] = tmp;
      Ne++;
    }
    else if (tmp > 0)
    {
      p[Po] = tmp;
      Po++;
    }
    else if (tmp == 0)
    {
      has_zero = true;
    }
  }
  p.resize(Po);
  n.resize(Ne);

  bool minus = false;
  int k = K - Po;
  if (k > Ne)
  {
    cout << 0 << endl;
    return 0;
  }
  else
  {
    if (k % 2 != 0)
    {
      if (Po > 0 && k + 1 <= Ne)
      {
        // ans is positive value
      }
      else
      {
        if (has_zero)
        {
          cout << 0 << endl;
          return 0;
        }
        else
        {
          minus = true;
        }
      }
    }
  }

  long long num = 1;
  if (K == N)
  {
    for (const auto a : n)
    {
      num = num * a % MOD;
      if (num < 0)
      {
        num += MOD;
      }
    }

    for (const auto a : p)
    {
      num = num * a % MOD;
    }
  }
  else if (!minus)
  {
    std::sort(n.begin(), n.end());
    std::sort(p.begin(), p.end(), std::greater<int>());

    if (K % 2 != 0) {
      num *= p[0];
      p.erase(p.begin());
      K--;
      Po--;
    }
    
    int i_n = 0;
    int i_p = 0;
    while (K > 1)
    {
      long long positive_n = -1;
      if (Po - i_p >= 2)
      {
        positive_n = p[i_p] * p[i_p + 1];
      }
      long long negative_n = -1;
      if (Ne - i_n >= 2)
      {
        negative_n = n[i_n] * n[i_n + 1];
      }

      if (positive_n > negative_n)
      {
        num = positive_n % MOD * num % MOD;
        i_p++;
        i_p++;
      }
      else
      {
        num = negative_n % MOD * num % MOD;
        i_n++;
        i_n++;
      }
      K--;
      K--;
    }

    if (K == 1)
    {
      num = num * p[i_p] % MOD;
    }
  }
  else
  {
    std::sort(n.begin(), n.end(), std::greater<int>());
    std::sort(p.begin(), p.end());
    
    int i_n = 0;
    int i_p = 0;
    while (K > 1)
    {
      long long positive_n = -1;
      if (Po - i_p >= 2)
      {
        positive_n = p[i_p] * p[i_p + 1];
      }
      long long negative_n = -1;
      if (Ne - i_n >= 2)
      {
        negative_n = n[i_n] * n[i_n + 1];
      }

      if (negative_n == -1 || (positive_n != -1 && (positive_n < negative_n)))
      {
        num = positive_n % MOD * num % MOD;
        i_p++;
        i_p++;
      }
      else
      {
        num = negative_n % MOD * num % MOD;
        i_n++;
        i_n++;
      }
      K--;
      K--;
    }

    if (K == 1)
    {
      num = num * n[i_n] % MOD;
      if (num < 0)
        num += MOD;
    }
  }

  cout << num << endl;

  return 0;
}


Measured memory_bytes: 6440
#include <iostream>
#include <stdio.h>

using namespace std;
int main(void){
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++)cin>>A[i];
    
    for(int i=n-1;i>=0;i--){
        cout<<A[i];
        if(i>0)cout<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3068
import Control.Applicative
import Control.Monad
import Data.List

isort :: [Int] -> ( [Int], [[Int]])
isort [x] = ( [x], [[x]] )
isort (x:xs) = (x',logging ++ [reverse x'])
               where (sorted,logging) = isort xs
                     x' = filter(> x) sorted ++ [x] ++ filter(<= x) sorted

complete y x = x ++ drop (length x) y


main = do 
    _ <- getLine
    x <- (map read.words) <$> getLine
    let (_,logging) = isort.reverse $ x 
    let a = intercalate "\n" $ map (unwords.map show.complete x) logging
    putStrLn $ a

Measured memory_bytes: 4176
#include <iostream>
#include <vector>
 
using namespace std;
 
int main(){
  	int H,N;
    int input,sum=0;  
    vector<int> A;
  	cin >> H >> N;
  	for(int i=0;i<N;i++){
      cin >> input;
      A.push_back(input);
    }
  	for(int i=0;i<A.size();i++){
      sum+=A[i];
	}
	if(sum>=H)
      cout << "Yes" << endl;
	else
      cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,y,ans;
  cin>>x>>y;
  ans=0;
  if(x==3){
    ans=ans+100000;
  }
  if(y==3){
    ans=ans+100000;
  }
  if(x==2){
    ans=ans+200000;
  }
  if(y==2){
    ans=ans+200000;
  }
  if(x==1){
    ans=ans+300000;
  }
  if(y==1){
    ans=ans+300000;
  }
  if(x==1 && y==1){
    ans=ans+400000;
  }
  cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int p = Integer.parseInt(sc.next());
    int q = Integer.parseInt(sc.next());
    int r = Integer.parseInt(sc.next());
    
    System.out.println(p + r + q -  Math.max(p,Math.max(q,r)));
  }

}


Measured memory_bytes: 21972
N = int(input())
A = list(map(int, input().split()))
count=0
while True:
  for i in A:
    if i%2 != 0:
      print(int(count))
      quit()
  
  A = list(map(lambda x: x/2, A))
  #print(A)
  count+=1
  #break
print(int(count))

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

using namespace std;
inline void read(long long &x) {
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}
inline void write(long long x) {
    static const long long maxlen = 100;
    static char s[maxlen];
    if (x < 0) {   putchar('-'); x = -x;}
    if (!x) { putchar('0'); return; }
    long long len = 0; for (; x; x /= 10) s[len++] = x % 10 + '0';
    for (long long i = len - 1; i >= 0; --i) putchar(s[i]);
}

inline void read(int &x){
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}

const long long MAXN =1001000;

long long n;
struct kt{
long long x,y;
long long id;
}a[ MAXN ];

long long fa[ MAXN ];


struct edge{
long long x,y,val;
}E[ MAXN*2 ];

bool cmp_x(kt A,kt B){
return A.x<B.x;
}

bool cmp_y(kt A,kt B){
return A.y<B.y;
}

bool cmp_e(edge A,edge B){
return A.val<B.val;
}

long long get_fa(long long x){
return (fa[x]==x)?(x):(fa[x]=get_fa(fa[x]));
}


int main(){
    read(n);
    for (long long i=1;i<=n;i++)
    {
        a[i].id=i;
        read(a[i].x);read(a[i].y);
    }
    sort(a+1,a+n+1,cmp_x);
    long long cnt=0;
    for (long long i=1;i<n;i++)
        {
            ++cnt;
            E[cnt].x=a[i].id;
            E[cnt].y=a[i+1].id;
            E[cnt].val=a[i+1].x-a[i].x;
        }

    sort(a+1,a+n+1,cmp_y);
    for (long long i=1;i<n;i++)
        {
            ++cnt;
            E[cnt].x=a[i].id;
            E[cnt].y=a[i+1].id;
            E[cnt].val=a[i+1].y-a[i].y;
        }
    for (long long i=1;i<=n;i++)
        fa[i]=i;

    sort(E+1,E+cnt+1,cmp_e);
    long long ans=0;
    for (long long i=1;i<=cnt;i++)
        {
            long long a=E[i].x,b=E[i].y;
            long long x=get_fa(a),y=get_fa(b);
            if ( x!=y )
                {
                    ans+=E[i].val;
                    fa[x]=y;
                }
        }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 14592
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int n;
    cin>>n;
    rep(i,n) {
		int in;
		cin >> in;
		if (in % 2 == 0 && (in % 3 != 0 && in % 5 != 0)) {
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout<<"APPROVED"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int mn,profit,data,temp,ptemp,i;
  mn = 1000000001;
  profit = -2000000003;
  scanf("%d",&data);
  scanf("%d",&mn);
  for(i=0;i<data-1;i++){
    scanf("%d",&temp);
    ptemp = temp - mn;
    if(ptemp > profit)profit = ptemp;
    if(mn > temp)mn = temp;
      }
  printf("%d\n",profit);

  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, a[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    int res = 0;
    int i = 1;
    while (i <= n) {
        res++;
        while (i < n && a[i] == a[i + 1]) i++;
        if (i == n) break;
        if (i < n && a[i] < a[i + 1]) {
            while (i < n && a[i] <= a[i + 1]) i++;
        } else {
            while (i < n && a[i] >= a[i + 1]) i++;
        }
        i++;
    }
    cout << res << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

class Solver {
    public void Solve() {
        long n = sc.nextLong();
        long b = sc.nextLong();
        long r = sc.nextLong();
        long sum = b + r;
        long ans = 0;
        if (b == 0) {
            System.out.println(0);
            return;
        }
        ans += n / sum * b;
        if (n % sum != 0) {
            long res = (n - (n / sum) * sum);
            ans += Math.min(res, b);
        }
        System.out.println(ans);
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
}


Measured memory_bytes: 22100
from collections import defaultdict
N, K = map(int, input().split())
check = defaultdict(lambda : False)
for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        check[a] = True
ans = 0
for i in range(1, N+1):
    if not check[i]:
        ans += 1
print(ans)

Measured memory_bytes: 9472
#include<stdio.h>

int BinarySearch(int ary[],int n,int key){
  int l=0,m,r=n;
  while(l<r){
    m=(l+r)/2;
    if(ary[m]==key){return 1;}
    if(key<ary[m]){r=m;}
    else{l=m+1;}
  }
  return 0;
}

int main(){
  int i,ary[1000000],judge=0,n,key,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&ary[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(BinarySearch(ary,n,key))judge++;
  }
  printf("%d\n",judge);
  return 0;
}



Measured memory_bytes: 2144
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <vector>
#define N 101000
using namespace std;
int m, n;
int a[111];
vector<int>ans, odd, even, x;

int main(){
	int i;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= m; ++ i){
		scanf("%d", &a[i]);
		if (a[i] % 2) odd.push_back(a[i]);
		else even.push_back(a[i]);
	}
	if (odd.size() >= 3){
		puts("Impossible");
		return 0;
	}
	if (odd.size())  ans.push_back(odd[0]);
	for (i = 0; i < even.size(); ++ i)
		ans.push_back(even[i]);
	if (odd.size() == 2) ans.push_back(odd[1]);

	for (i = 0; i < ans.size(); ++ i)
		printf("%d%c", ans[i], i < ans.size() - 1 ? ' ' : '\n');
	if (ans[0] > 1)  x.push_back(ans[0] - 1);
	for (i = 1; i < ans.size(); ++ i)
	if (ans[i] % 2)  {
		x.push_back(2);
		if(ans[i] > 1) x.push_back(ans[i] - 1);
	}
	else x.push_back(ans[i]);
	if (odd.size() <= 1) x.push_back(1);
	printf("%d\n", x.size());
	for (i = 0; i < x.size(); ++ i)
		printf("%d%c", x[i], i < x.size() - 1 ? ' ' : '\n');
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

// aの約数を全て返す
vector<ll> divisor(ll a){
	vector<ll> res;
	for(ll i = 1; i*i <= a; i++){
		if(a%i == 0){
			res.push_back(i);
			if(i != a/i) res.push_back(a/i);
		}
	}
	return res;
}

int mainsolve(){

	ll n;
	cin >> n;

	ll res = 0;
	res += divisor(n-1).size() - 1; // n-1の約数から1を除いたもの

	vector<ll> div = divisor(n);
	for(ll k : div){
		if(k==1) continue;

		ll now = n;
		while(now >= k && now%k == 0) now /= k;

		if(now % k == 1) res++;
	}

	cout << res << endl;

	return 0;
}
int main(){

	return mainsolve();
}

Measured memory_bytes: 384
N = int(input())
li = []
for _ in range(N):
    li.append(int(input()))

li.sort()
if sum(li) % 10 != 0:
    print(sum(li))
else:
    for i in range(N):
        if li[i] % 10 != 0:
            print(sum(li) - li[i])
            exit()

    print(0)


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

int main(){
	int n;	cin >> n;
  	vector<int> x(n);	for(int i = 0; i < n; i++){cin >> x.at(i);}
  	
  	int mx = 1000000;
  	for(int i = 1; i <= 100; i++){
      	int tmp = 0;
      	for(int j = 0; j < n; j++){
        tmp += pow((x.at(j) - i),2);}
      	mx = min(tmp,mx);
    }
    cout << mx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  int a, b, n;
  cin >> a >> b >> n;
  cout << (a + b) * n / 2 << endl;
  return 0;
}

Measured memory_bytes: 256