akhauriyash/Code-Regression huggingface dataset:
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

long h;
long w;

void main()
{
    scan(h, w);
    auto s = new string[](h);
    foreach (i; iota(h))
        s[i] = sread();
    auto starts = new Pair[](0);
    foreach (i; iota(h))
        foreach (j; iota(w))
            if (s[i][j] != '#')
                starts ~= Pair(i, j);

    long max_dist;
    foreach (e; starts)
    {
        max_dist = max(s.rootlen(e), max_dist);
    }
    max_dist.writeln();
}

auto rootlen(T)(T s, Pair p)
{
    // 幅優先探索で一番遠い点を見つける
    // スタート地点がp
    auto dist = new long[][](h, w);
    dist[p.x][p.y] = -1;
    auto Q = DList!Pair(p);
    while (!Q.empty)
    {
        auto current = Q.front;
        Q.removeFront();
        if (current.x - 1 >= 0 && dist[current.x - 1][current.y] == 0)
        {
            if (s[current.x - 1][current.y] != '#')
            {
                Q.insertBack(Pair(current.x - 1, current.y));
                dist[current.x - 1][current.y] = dist[current.x][current.y] + 1;
            }
            else
                dist[current.x - 1][current.y] = -1;
        }
        if (current.x + 1 < h && dist[current.x + 1][current.y] == 0)
        {
            if (s[current.x + 1][current.y] != '#')
            {
                Q.insertBack(Pair(current.x + 1, current.y));
                dist[current.x + 1][current.y] = dist[current.x][current.y] + 1;
            }
            else
                dist[current.x + 1][current.y] = -1;

        }
        if (current.y - 1 >= 0 && dist[current.x][current.y - 1] == 0)
        {
            if (s[current.x][current.y - 1] != '#')
            {
                Q.insertBack(Pair(current.x, current.y - 1));
                dist[current.x][current.y - 1] = dist[current.x][current.y] + 1;
            }
            else
                dist[current.x][current.y - 1] = -1;
        }
        if (current.y + 1 < w && dist[current.x][current.y + 1] == 0)
        {
            if (s[current.x][current.y + 1] != '#')
            {
                Q.insertBack(Pair(current.x, current.y + 1));
                dist[current.x][current.y + 1] = dist[current.x][current.y] + 1;
            }
            else
                dist[current.x][current.y + 1] = -1;
        }
    }
    long maxdist;
    foreach (i; iota(h))
    {
        foreach (j; iota(w))
        {
            maxdist = max(dist[i][j], maxdist);
        }
    }
    return maxdist + 1;
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 1276
#include<stdio.h>
int main()
{
    int A,B,C,T,temp;
    scanf("%d %d %d",&A,&B,&C);
        if(C>A&&C<B){
            printf("Yes\n");
        }
        else if(C==A&&C==B){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    return 0;
}


Measured memory_bytes: 128
from itertools import product, permutations

def check(x, n):
    ex = ['((({0} {4} {1}) {5} {2}) {6} {3})',
        '(({0} {4} {1}) {5} ({2} {6} {3}))']
    for nums in permutations(x):
        for ops in product('+-*', repeat=3):
            for e in ex:
                eq = e.format(*(nums+ops))
                if eval(eq)==n: return eq
    return ''

n=10
while True:
    x = map(int,raw_input().split())
    if x==[0,0,0,0]: break
    s = check(x,n)
    if s!='': print s
    else: print ('0')

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int r = 0, l = 0;
    int i = 0;
    int *n = new int[s.size()];
    for (int j = 0; j < s.size(); ++j) n[j] = 0;
    while (i < s.size()) {
        if (i == s.size() - 1) {
            break;
        }
        for(r = 0; s[i] == 'R'; ++i) {
            r++;
        }
        n[i - 1] = (r + 1) / 2;
        n[i] = r / 2;
        int idx = i;
        for (l = 0; s[i] == 'L'; ++i) {
            l++;
        }
        n[idx - 1] += l / 2;
        n[idx] += (l + 1) / 2;
    }
    for (int i = 0; i < s.size(); ++i) {
        cout << n[i] << " ";
    }
    cout << endl;
    delete[] n;
    return 0;
}

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

int main(void)
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  int A, B, C, D; cin >> A >> B >> C >> D;

  string ans;

  while (true) {
    C -= B; if (C <= 0) { ans = "Yes"; break; }
    A -= D; if (A <= 0) { ans = "No";  break; }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
    int n, q;
    cin >> n >> q;
    vector<long long> s(n, 0), ans(n);
    vector<vector<int>> k(n);
    queue<int> pq;
    vector<bool> d(n,1);
    for(int i=0; i<n-1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        k[a].push_back(b);
        k[b].push_back(a);
    }
    for(int i=0; i<q; i++) {
        int p, x;
        cin >> p >> x;
        p--;
        s[p]+=x;
    }

    pq.push(0);
    while(!(pq.empty())) {
        int a;
        a=pq.front();
        pq.pop();
        ans[a]=s[a];
        d[a]=0;
        for(int j=0; j<k[a].size(); j++) {
            if(d[k[a][j]]) {
                s[k[a][j]]+=s[a];
                pq.push(k[a][j]);
            }
        }
    }
    for(int i=0; i<n; i++) {
        cout << ans[i] << " ";
    }
}

Measured memory_bytes: 17908
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    int n;
    cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];

    const ll mod = 1e9+7;

    vl dp_j(n+1);

    for(int i = n-1; i >= 0; i--){
        dp_j[i] = (dp_j[i+1] + a[i])% mod;
    }

    // rep(i,n){
    //     cout << dp_j[i] << endl;
    // }

    // rep(i,n){
    //     dp_j[i+1] = (dp_j[i] + a[i]) % mod; 
    // }

    ll ans = 0;
    rep(i,n-1){
        ll tmp = (a[i] * dp_j[i+1]) % mod;
        ans = (ans+tmp)%mod;
    }

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

Measured memory_bytes: 6368
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
/*ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
*/


/*最小公倍数*/
/*
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
*/

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll>>p;
    for(ll i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        p.push_back(make_pair(a,b));
    }
    bool flag=true;
    string a;
    for(ll i=0;i<1000;i++){
        a=to_string(i);
        flag=true;
        for(ll j=0;j<m;j++){
            if(a[p[j].first-1]!=p[j].second+'0'){
                flag=false;
                break;
            }
            
        }
        if(flag&&a.size()==n){
            cout<<i<<endl;
            exit(0);
        }
        
    }
    cout<<-1<<endl;

    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  string s;
  cin >> s;
  int num = s.size();
  char check = s[num-1];
  if (check == 's') cout << s << "es" << endl;
  else cout << s << 's' << endl;
  
return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

const int CountCommonCharNum(const string &X, const string &Y)
{
    set<char> charSet;
    for (const char x : X)
    {
        charSet.insert(x);
    }
    int count = 0;
    for (const char x : charSet)
    {
        if (Y.find(x) != -1) ++count;
    }
    return count;
}

int main()
{
    int N;
    string S;
    cin >> N >> S;
    string X, Y;
    Y = S.back();
    S.pop_back();
    X = S;
    int maxCount = 0;
    for (int i = 0; i < N - 1; ++i)
    {
        int count = CountCommonCharNum(X, Y);
        if (count > maxCount)
        {
            maxCount = count;
        }
        Y = Y + X.back();
        X.pop_back();
    }
    cout << maxCount << endl;

    return 0;
}

Measured memory_bytes: 256
a,b,c= map(int,input().split())
if(a<b):
	if(b<c):
		print(a,b,c)
	elif(c<a):
		print(c,a,b)
	else:
		print(a,c,b)
else:
	if(a<c):
		print(b,a,c)
	elif(c<b):
		print(c,b,a)
	else:
		print(b,c,a)

Measured memory_bytes: 7648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n; cin>>n;
  vector<ll> sum(n,0),calc(n+1,0);
  cin>>sum[0];
  calc[0]=calc[1]=0;
  for(int i=1;i<n;i++){
    ll a; cin>>a;
    sum[i]=sum[i-1]+a;
    calc[i+1]=calc[i]+i;
  }
  ll ans=0;
  sort(sum.begin(),sum.end());
  if(sum[0]==0) ans++;
  for(int i=0;i<n;i++){
    int c=1,log=i+1;
    while(log<n){
      if(sum[log]==0) ans++;
      if(sum[i]==sum[log]){
        c++; log++;
      }else break;
    }
    ans+=calc[c];
    i=log-1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1e18;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define all(x) (x).begin(), (x).end()

// 10進数 n の桁数を求める
ll num_digit(ll n) {
    ll res = 0;
    while (n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

ll N;

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

    cin >> N;
    ll ans = INF;
    for (ll a=1; a*a<=N; a++) {
        if (N%a == 0) {
            ll b = N/a;
            ans = min(ans, max(num_digit(a), num_digit(b)));
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s, t;
    cin >> s >> t;

    int n = s.length();
    bool c = true;
    rep(i, n) {
        if (s[i] != t[i]) c = false;
    }
    if (c) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

const int NMAX = 100000;
int isprime[NMAX + 1];


void eratos(int n) {
	REP(i, n) {
		isprime[i] = 1;
	}
	isprime[0] = 0;
	isprime[1] = 0;
	FOR(i, 2, n) {
		if (isprime[i]) {
			FOR(j, i + 1, n) {
				if (j%i == 0) {
					isprime[j] = 0;
				}
			}
		}
	}
}


int main() {
	int Q, l, r, S[100001] = { 0 };

	eratos(100001);
	FOR(i, 1, 100001) {
		if (isprime[i] && isprime[(i + 1) / 2]) {
			S[i] = S[i - 1] + 1;
		}
		else {
			S[i] = S[i - 1];
		}
	}

	cin >> Q;
	REP(i, Q) {
		cin >> l >> r;
		cout << S[r] - S[l - 1] << endl;
	}


	return 0;
}

Measured memory_bytes: 1408
import numpy as np

N, M, X = map(int, input().split())
c = []
a = []
for i in range(N):
    tmp = list(map(int, input().split()))
    c.append(tmp[0])
    a.append(tmp[1:])
c = np.array(c)
a = np.array(a)
min_money = 10 ** 8
flag = False
for i in range(2 ** N):
    order = []
    for j in range(N):
        if (i >> j) & 1:
            order.append(j)
    if not len(order):
        continue
    rikaido = np.sum(a[np.array(order)], axis=0)
    if np.all(rikaido >= X):
        flag = True
        money = np.sum(c[order])
        if min_money > money:
            min_money = money
if flag:
    print(min_money)
else:
    print(-1)

Measured memory_bytes: 27336
import java.util.Scanner;

public class Main{
    void run(){
        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h+w == 0) break;

            int minHeight = 1000;
            int minWidth = 1000;
            for(int height=1; height<=200; height++){
                for(int width=height+1; width<=200; width++){
                    if(compalableRectangles(h, w, height, width) == -1 && compalableRectangles(height, width, minHeight, minWidth) == -1){
                        minHeight = height;
                        minWidth = width;
                    }
                }
            }
            System.out.println(minHeight + " " + minWidth);
        }
    }

    int compalableRectangles(int h1, int w1, int h2, int w2){
        int c1 = h1*h1+w1*w1;
        int c2 = h2*h2+w2*w2;
        if(c2 < c1){
            return 1;
        }
        if(c1 < c2){
            return -1;
        }
        if(c1 == c2){
            if(h1 == h2){
                return 0;
            }
            if(h2 < h1){
                return 1;
            }
            if(h1 < h2){
                return -1;
            }
        }
        return -100;
    }
    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 20564
#include<iostream>
#include<algorithm>
#include<vector>

int main(void){
    long long a, b, c;
    std::cin >> a >> b >> c;

    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
        std::cout << 0 << std::endl;
        return 0;
    }

    std::vector<long long> ar = {a, b, c};
    std::sort(ar.begin(), ar.end());

    long long ans = ar[0] * ar[1];
    std::cout << ans << std::endl;
    return 0;

}

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

int main()
{
  long long n;
  long long ans = 0, p;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    p = n/i;
    ans += p*(p+1)/2*i;
  }
  cout << ans << endl;
}

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

int main() {
  ll H;
  cin >> H;

  int exp = 0;
  while (H / 2 != 0) {
    exp++;
    H = H / 2;
  }

  ll cnt = 0;
  for (int i = 0; i <= exp; i++) {
    cnt += pow(2, i);
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s < t){
        print("Yes");
    }else{
        print("No");
    }
    

}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
	Scanner sc = new Scanner(System.in);

	public static void main(String[] args)
	{
		new Main().run();
	}

	void run()
	{
		int n = Integer.parseInt(sc.nextLine());
		while(n-- > 0)
		{
			String str = sc.nextLine();
			Parser p = new Parser(str);
			int res = p.get().need();
			System.out.println(res);
		}
	}
}

class Parser
{
	String str;
	int index = 0;

	Calcuable c;
	Deque<Calcuable> stack = new ArrayDeque<>();

	public Parser(String s)
	{
		str = s;
		c = new BlockGroup();
		stack.push(c);
		parse();
	}

	Calcuable get()
	{
		return c;
	}

	void parse()
	{
		while(true)
		{
			int r = read();
			if(r==-3) return;
			if(r == -1)
			{
				stack.pop();
			}
			else if(r == -2)
			{
				BlockGroup bg = new BlockGroup();
				((BlockGroup)stack.peek()).add(bg);
				stack.push(bg);
			}
			else
			{
				((BlockGroup) stack.peek()).add(new Block(r));
			}
		}
	}

	int read()
	{
		if(index==str.length())
		{
			return -3;
		}
		else if(str.charAt(index) == ']')
		{
			index++;
			return -1;
		}
		else if(str.charAt(index) == '[')
		{
			index++;
			return -2;
		}
		else
		{
			int v = 0;
			while(str.charAt(index) != ']')
			{
				v *= 10;
				v += (str.charAt(index) - '0');
				index++;
			}
			return v;
		}
	}

}

interface Calcuable
{
	int need();
}

class Block implements Calcuable
{
	int num;

	public Block(int n)
	{
		num = n;
	}

	@Override
	public String toString()
	{
		return Integer.toString(num);
	}

	@Override
	public int need()
	{
		return (num + 1) / 2;
	}
}

class BlockGroup implements Calcuable
{
	ArrayList<Calcuable> blocks = new ArrayList<>();

	public BlockGroup()
	{
	}

	void add(Calcuable c)
	{
		blocks.add(c);
	}

	@Override
	public String toString()
	{
		return blocks.toString();
	}

	@Override
	public int need()
	{
		int[] needs = new int[blocks.size()];
		for(int i = 0; i < needs.length; i++)
		{
			needs[i] = blocks.get(i).need();
		}
		Arrays.sort(needs);
		int sum = 0;
		int lim = (needs.length + 1) / 2;
		for(int i = 0; i < lim; i++)
			sum += needs[i];
		return sum;
	}

}

Measured memory_bytes: 42084
cn = $stdin.readline.to_i

1.step(3500) do |h|
  h.step(3500) do |n|
    rem = 4 * h * n - cn * h - cn * n
    next if rem < 1
    num = n * h * cn
    if num % rem == 0
      w = num / rem
      puts [h, n, w].join(" ")
      exit
    end
  end
end


Measured memory_bytes: 14328
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n; i++){
        cin >> a[i];
    }

    vector<ll> l(n+1, 0), r(n+1, 0);
    for(ll i = 1; i <= n; i++) l[i] = gcd(l[i - 1], a[i - 1]);
    for(ll i = n - 1; i >= 0; i--) r[i] = gcd(r[i + 1], a[i]);

    int ans = 0;
    for(ll i = 1; i <= n; i++){
        ans = max(ans, gcd(l[i - 1], r[i]));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
<?php
$input = explode(' ', trim(fgets(STDIN)));;

$n = (int)$input[0];
$m = (int)$input[1];
$from = [];
$to = [];
for ($i=0; $i < $m; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));;
	if ($input[0] == 1) {
		$from[] = (int)$input[1];
	}elseif ($input[1] == $n) {
		$to[] = (int)$input[0];
	}
}

$check = count($from);
$diff = count(array_diff($from, $to));

if ($check !== $diff) {
	echo 'POSSIBLE';
}else{
	echo 'IMPOSSIBLE';
}

Measured memory_bytes: 22132
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    n: usize,
    }

    let mut a = vec![];
    let mut b = vec![];

    for _ in 0..n {
      input!{
        x:i64,
        y:i64,
      }
      a.push(x + y);
      b.push(x - y);
    }

    a.sort();
    b.sort();

    let ans = max!(a[a.len() -1]-a[0], b[b.len() -1] - b[0]);


     println!("{}", ans);
}


Measured memory_bytes: 9780
# input here
_INPUT = """\
1000 1 1000
"""

def main():
    n, x, t = map(int, input().split())

    print((math.ceil(n / x))*t)


if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools

    # sys.stdin = io.StringIO(_INPUT)
    main()

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

int main() {
  string S, T;
  cin >> S >> T;
  
  map<char, char> Tie;
  bool fg = 1;
  for( int i = 0; i < (int)S.size(); i++ ){
    if( Tie.count(S.at(i)) ){
      if( Tie.at(S.at(i)) != T.at(i) ) fg = 0;
    }else Tie[S.at(i)] = T.at(i);
  }
  
  map<char, char> Tie2;
  for( int i = 0; i < (int)T.size(); i++ ){
    if( Tie2.count(T.at(i)) ){
      if( Tie2.at(T.at(i)) != S.at(i) ) fg = 0;
    }else Tie2[T.at(i)] = S.at(i);
  }
  
  if( fg ) cout << "Yes" << endl;
  else cout << "No" << endl;
}



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

using namespace std;

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

    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);

    if ((a[0]==a[1] && a[0]!=a[2]) || (a[1]==a[2] && a[0]!=a[2]))
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


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

const int MAX = 100005;

int main() {
	int n, m;
	cin >> n >> m;
	vector<pii> p(n), c(n);
	rep(i, n) cin >> p[i].first >> p[i].second;
	rep(i, m) cin >> c[i].first >> c[i].second;
	rep(i, n) {
		int mn = 1e9, ans = 0;
		rep(j, m) {
			int dx = abs(p[i].first - c[j].first);
			int dy = abs(p[i].second - c[j].second);
			if (dx + dy < mn) {
				mn = dx + dy;
				ans = j;
			}
		}
		cout << ans + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    int  n,q; cin >> n >> q;
    string s; cin >> s;
    vector<int> l(q);
    vector<int> r(q);
    rep(i,q){
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
    }
    vector<int> b(n + 1);
    b[0] = 0;
    for(int i = 1; i <= n; i++){
        if(s[i - 1] == 'A' && s[i] == 'C'){
            b[i] = b[i - 1] + 1;
        }else{
            b[i] = b[i - 1];
        }
    }

    for(int i = 0; i < q; i++){
        cout << b[r[i]] - b[l[i]] << endl;
    }
}

Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iomanip>

using namespace std;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a,b,c=0;
	cin>>a>>b;
	if(a>=b){
		c+=a;
		a--;
	}
	else{
		c+=b;
		b--;
	}
	if(a>=b){
		c+=a;
		a--;
	}
	else{
		c+=b;
		b--;
	}
	cout<<c<<endl;	
	return 0;
}


Measured memory_bytes: 256
let js = Array.make 10 true
let rec f n = n = 0 || js.(n mod 10) && f (n / 10)
let _ = Scanf.scanf " %d %d" @@ fun n k -> for _ = 1 to k do js.(Scanf.scanf " %d" (+) 0) <- false done; for i = n to 100000 do if f i then (Printf.printf "%d\n" i; exit 0) done

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }

    vector<bool> F(n, true);
    int pos = 1;
    do{
        F[pos-1] = false;
        pos = A[pos-1];
    }while(F[pos-1]);
    int rep_pos = pos;

    int pre = 0, rep = 0;
    pos = 1;
    while(pos != rep_pos){
        pos = A[pos-1];
        pre++;
    }
    do{
        pos = A[pos-1];
        rep++;
    }while(pos != rep_pos);

    if(k <= pre){
        pos = 1;
        for(int i=0;i<k;i++){
            pos = A[pos-1];
        }
    }
    else{
        pos = rep_pos;
        k -= pre;
        int count = k % rep;
        for(int i=0;i<count;i++){
            pos = A[pos-1];
        }
    }

    cout << pos << endl;
    return 0;
}

Measured memory_bytes: 4060
class UnionFind():
    def __init__(self, n):
        self.n = 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 union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
ans = [0] * (M)
ans[M-1] = N * (N - 1) // 2
uf = UnionFind(N)
for i in range(M-1,0,-1):
  if uf.same(AB[i][0]-1,AB[i][1]-1):
    ans[i-1] = ans[i]
  else:
    ans[i-1] = ans[i] - uf.size(AB[i][0]-1) * uf.size(AB[i][1]-1)
  uf.union(AB[i][0]-1,AB[i][1]-1)
print(*ans,sep="\n")

Measured memory_bytes: 36184
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<vector>
#include<math.h>

using namespace std;
int main(){
    string s, p;
    cin >> s >> p;
    s = s + s;
    
    if(s.find(p) != -1) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}
           

Measured memory_bytes: 3160
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll x,y;
    cin>>x>>y;
    ll ans=10000000000000000;
    if(x<=y){
        ans=min(ans,y-x);
    }
    if(-x<=y){
        ans=min(ans,y+x+1);
    }
    if(x<=-y){
        ans=min(ans,-y-x+1);
    }
    if(-x<=-y){
        ans=min(ans,-y+x+2);
    }
    cout<<ans<<endl;
    
}


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

using namespace std;

int64_t my_pow(int n,int p){
  int64_t res = 1;
  while(p){
    if(p & 1)res *= n;
    n *= n;
    p >>= 1;
  }
  return res;
}

int howmanytwo(int64_t n){
  int res = 0;
  while(1){
    if(n & 1)break;
    res++;
    n >>= 1;
  }
  return res;
}

int main(){
  int64_t n,m,gcd_,lcm = 1,res = 0;
  cin >> n >> m;
  vector<int64_t> v(n);
  for(int i = 0;i < n;i++)cin >> v[i];
  sort(v.begin(),v.end(),greater<int64_t>());
  int two = howmanytwo(v[0]);
  for(int i = 1;i < n;i++){
    if(two != howmanytwo(v[i])){
      cout << 0;
      return 0;
    }
  }
  lcm = v[0];
  for(int i = 1;i < n;i++)lcm = v[i]*lcm/__gcd(lcm,v[i]);
  int64_t _2lcm = lcm/2;
  for(int i = 1;_2lcm*i <= m;i+=2){
    if(_2lcm*i < v[0]/2)continue;
    res++;
  }
  cout << res;
  return 0;
}


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

int main() {
  LL n, m;
  cin >> n >> m;
  vector<LL> a(n);
  for (int i = 0; i < n; i ++) cin >> a[i];
  sort(a.begin(), a.end());

  pair<LL, LL> p[m];
  for (int i = 0; i < m; i ++) {
    int b, c;
    cin >> b >> c;
    p[i].first = c, p[i].second = b;
  }
  sort(p, p + m);
  reverse(p, p + m);

  LL left = 0, right;
  LL ans = 0;
  for (int i = 0; i < m; i ++) {
    if (left >= n) break;

    right = lower_bound(a.begin() + left, min(a.begin() + left + p[i].second - 1, a.end() - 1), p[i].first) - a.begin();
    if (a[right] > p[i].first) {
      ans += p[i].first * (right - left);
      left = right;
    } else if (a[left] < p[i].first) {
      ans += p[i].first * (right - left + 1);
      left = right + 1;
    } else {
      break;
    }
  }
  if (left < n) {
    for (int i = left; i < n; i ++) ans += a[i];
  }

  cout << ans << endl;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
template<class T> constexpr bool in_range(T y, T x, T H, T W) { return 0<=y&&y<H&&0<=x&&x<W; }

int N;
int a[5][5];
int b[5][5];
int score[6];

void drop() {
  rep(j, 5) {
    deque<int> d;
    rep(i, 5) {
      if(a[i][j] != -1) {
        d.push_back(a[i][j]);
      }
    }

    int dsize = d.size();
    for(int i=4; i>=0 && !d.empty(); i--) {
      a[i][j] = d.back();
      d.pop_back();
    }
    rep(i, 5-dsize) {
      a[i][j] = -1;
    }
  }
}

int dist(int num, int i, int j, int dy, int dx, int sum = 0) {
  i += dy, j += dx;
  if(!in_range(i, j, 5, 5)) return sum;
  if(a[i][j] != num) return sum;
  return dist(num, i, j, dy, dx, sum + 1);
}

int simulate() {
  int ret = 0;
  int bonus = 1;

  while(1) {
    set<int> used;
    rep(i, 5) rep(j, 5) {
      if(a[i][j] == -1) continue;
      int movel = dist(a[i][j], i, j, 0, -1);
      int mover = dist(a[i][j], i, j, 0, +1);
      int movet = dist(a[i][j], i, j, -1, 0);
      int moveb = dist(a[i][j], i, j, +1, 0);
      if(mover - movel + 1 >= 3) {
        REP(x, j - movel, j + mover + 1) {
          assert(a[i][x] != -1);
          assert(a[i][x] == a[i][j]);
          used.insert(i*5+x);
        }
      }
      if(moveb - movet + 1 >= 3) {
        REP(y, i - movet, i + moveb + 1) {
          assert(a[y][j] != -1);
          assert(a[y][j] == a[i][j]);
          used.insert(y*5+j);
        }
      }
    }

    for(auto && e: used) {
      ret += score[a[e/5][e%5]] * bonus;
      a[e/5][e%5] = -1;
    }

    bonus ++;
    if(!used.size()) break;
    drop();
  }

  return ret;
}



int dfs(int y, int x, int idx = 0) {
  int aa[5][5]; rep(i, 5) rep(j, 5) aa[i][j] = a[i][j];
  int ret = simulate();
  if(idx < N) {
    rep(k, 4) {
      int ny = y + dy[k], nx = x + dx[k];
      if(!in_range(ny, nx, 5, 5)) continue;
      rep(i, 5) rep(j, 5) a[i][j] = aa[i][j];
      swap(a[y][x], a[ny][nx]);
      maximize(ret, dfs(ny, nx, idx + 1));
    }
  }
  return ret;
}

int solve() {
  int ret = 0;
  rep(i, 5) rep(j, 5)  {
    rep(i, 5) rep(j, 5) a[i][j] = b[i][j];
    maximize(ret, dfs(i, j));
  }
  return ret;
}

int main() {

  for(; cin >> N && N >= 0;) {
    rep(i, 5) rep(j, 5) cin >> b[i][j], a[i][j] = b[i][j];
    rep(i, 5) cin >> score[i+1];
    cout << solve() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

int main()
{
    int a;
    std::map<char, long long int> m;
    cin >> a;
    string str = "MARCH";
    rep(i, a)
    {
        string temp;
        cin >> temp;
        rep(j, 5)
        {
            if (temp[0] == str[j])
            {
                m[temp[0]]++;
                break;
            }
        }
    }
    /*
    rep(i,5){
        cout<<m[str[i]];
    }
    cout<<endl;
    */
    long long int ans = 0;
    int flag = 1;
    REP(i, 0, 5)
    {
        REP(j, i + 1, 5)
        {
            REP(k, j + 1, 5)
            {
                ans += m[str[i]] * m[str[j]] *m[str[k]];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(n==i*j){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
int cnt = 0;
int res[200100][4];
void print_plus(int i, int j, int k) {
	res[cnt][0] = 0;
	res[cnt][1] = i;
	res[cnt][2] = j;
	res[cnt][3] = k;
	cnt++;
}
void print_comp(int i, int j, int k) {
	res[cnt][0] = 1;
	res[cnt][1] = i;
	res[cnt][2] = j;
	res[cnt][3] = k;
	cnt++;
}
int main() {
	print_plus(0, 1, 9);
	print_comp(3, 9, 10);
	print_plus(3, 3, 2);
	for (int i = 0; i < 40; i++) {
		print_plus(i + 10, i + 10, i + 11);
	}
	print_plus(0, 10, 0);
	print_plus(1, 10, 1);
	for (int i = 30; i >= 0; i--) {
		// 0 : in1
		// 1 : in2
		// 2 : out1
		// 3 : 0
		// 4 : 0..in1
		// 5 : turned on in1
		// 6 : 0..in2
		// 7 : turned on in2
		// 10 : 1
		print_plus(4, i + 10, 100);
		print_comp(100, 0, 5);
		print_comp(100, 0, 100);
		for (int k = 0; k < i; k++) {
			print_plus(100 + k, 100 + k, 101 + k);
		}
		print_plus(4, 100 + i, 4);
		print_plus(3, 3, 6);
		for (int j = 30; j >= 0; j--) {
			print_plus(6, j + 10, 100);
			print_comp(100, 1, 7);
			print_plus(5, 7, 8);
			print_comp(10, 8, 100);
			for (int k = 0; k < i + j; k++) {
				print_plus(100 + k, 100 + k, 101 + k);
			}
			print_plus(2, 100 + i + j, 2);
			print_plus(6, 100 + j, 6);
		}
	}
	printf("%d\n", cnt);
	for (int i = 0; i < cnt; i++) {
		if (res[i][0] == 0) {
			printf("+ %d %d %d\n", res[i][1], res[i][2], res[i][3]);
		}
		else {
			printf("< %d %d %d\n", res[i][1], res[i][2], res[i][3]);
		}
	}
	return 0;
}


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

int main() {
  int64_t n, s = 0;
  cin >> n;
  vector<int> a(n+1), b(n);
  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n){
    if(a[i] < b[i]){
      b[i] = min(b[i], a[i] + a[i+1]);
      a[i+1] -= b[i] - a[i];
    }
    s += b[i];
  }
  cout << s << endl;
  return 0;
}

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

using namespace std;


int main(int argv, char** argc) {
  int N;
  int min,min_i=0;
  long int sum=0;
  bool flag = false;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A.at(i);

  min = A.at(0);
  for(int i=0;i<N-1;i++){
    if(abs(min)>abs(A.at(i+1))){
      min=A.at(i+1);
      min_i=i+1;
    }
    if(A.at(i)<0){
      A.at(i)*=-1;
      A.at(i+1)*=-1;
    }
  }

  if(A.at(N-1)<0)
    flag=true;

  if(flag==true){
    for(int i=N-1;i>min_i;i--){
      A.at(i)*=-1;
      A.at(i-1)*=-1;
    }
  }
  for(int i=0;i<N;i++) sum += A.at(i);
  cout << sum;

  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        for (int i = 0; i < s.length(); i++) {
            if(s.equals(t)) {
                System.out.println("Yes");
                return;
            } else {
                s = s.substring(s.length() - 1, s.length()) + s.substring(0, s.length() -1 );
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 39408
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

int n, l, q, h[100010], dt[20][100010];

int main()
{
    scanf("%d", &n);
    for(int i = 1 ; i <= n ; i++ ) scanf("%d", h+i);
    scanf("%d%d", &l, &q);
    for(int i = 1 ; i <= n ; i++ )
        dt[0][i] = (int)(upper_bound(h+1, h+n+1, h[i]+l) - h) - 1;
    for(int j = 1 ; j < 20 ; j++ ) for(int i = 1 ; i <= n ; i++ )
        dt[j][i] = dt[j-1][dt[j-1][i]];
    while( q-- )
    {
        int a, b, cnt = 0, d;
        scanf("%d%d", &a, &b);
        if( a > b ) swap(a, b);
        for(int i = 19 ; i >= 0 ; i-- )
        {
            if( dt[i][a] < b )
            {
                cnt += (1<<i);
                a = dt[i][a];
            }
        }
        printf("%d\n", cnt+1);
    }
    return 0;
}


Measured memory_bytes: 8960
#include <stdio.h>
#define GOOD 1
#define BAD 0

int main(void){
    int n,m,h[100000],a,b;
    int i,x[100000],ans=0;
    scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++){
        scanf("%d",&h[i]);
        x[i] = GOOD;
    }

    for(i=1;i<=m;i++){
        scanf("%d %d",&a,&b);
        if(h[a] == h[b]){
            x[a] = BAD;
            x[b] = BAD;
        } 
        if(h[a] > h[b]) x[b] = BAD;
        if(h[a] < h[b]) x[a] = BAD;
    }

    for(i=1;i<=n;i++){
        if(x[i] == GOOD) ans++;
    }

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 2464
#include <bits/stdc++.h>
using namespace std;
#define LL long long
multiset <int> S;
const int N = 300000;
const int INF = 1e9;
int mn = INF, mx, n;
LL ans = 1e18;
int xi[N], yi[N], ord[N];
int comp(int a, int b)
{
    if (xi[a] != xi[b]) return xi[a] < xi[b];
    return yi[a] < yi[b];
}
int main()
{
    // freopen("sparse0.in", "r", stdin);
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i)
    {
        scanf("%d%d", &xi[i], &yi[i]);
        if (xi[i] > yi[i]) swap(xi[i], yi[i]);
    }
    for (int i = 1; i <= n; ++ i) ord[i] = i;
    sort(ord + 1, ord + n + 1, comp);

    for (int i = 2; i <= n; ++ i) S.insert(xi[ord[i]]); S.insert(yi[ord[1]]);
    for (int i = 1; i <= n; ++ i) mx = max(mx, yi[i]), mn = min(mn, xi[i]);
    for (int i = 2; ; ++ i)
    {
        auto ip = S.begin(), iq = S.end(); iq --;
        ans = min(ans, 1ll * (*iq - *ip) * (mx - mn));
        if (i == n + 1) break;
        S.erase(S.lower_bound(xi[ord[i]]));
        S.insert(yi[ord[i]]);
    }

    int mxa = 0, mxb = 0, mna = INF, mnb = INF;
    for (int i = 1; i <= n; ++ i)
    {
        if (xi[i] > mxa) mxa = xi[i];
        if (xi[i] < mna) mna = xi[i];
        if (yi[i] > mxb) mxb = yi[i];
        if (yi[i] < mnb) mnb = yi[i];
    }
    ans = min(ans, 1ll * (mxa - mna) * (mxb - mnb));
    printf("%lld\n", ans);
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int S=0; //各位の和
  string N;
  cin >> N;
  for(int i=0;i<N.size();i++){
    int n = N.at(i) - '0'; //文字を数値に
    S+=n;
}
  int D = stoi(N);
    if(D%S == 0){
      cout <<"Yes" << endl;
    }
  else {cout << "No" << endl;}


  }

Measured memory_bytes: 256
from collections import Counter

n,k,l=map(int,input().split())
city1=[i for i in range(n)]
city2=[i for i in range(n)]

def root(c,x):
  if x==c[x]:
    return x
  else:
    c[x]=root(c,c[x])
    return c[x]

def union(c,x,y):
  rx=root(c,x)
  ry=root(c,y)
  if rx>ry:
    c[rx]=ry
  else:
    c[ry]=rx

for i in range(k):
  a,b=map(int,input().split())
  union(city1,a-1,b-1)
for i in range(l):
  a,b=map(int,input().split())
  union(city2,a-1,b-1)
r=[]
for i in range(n):
  r.append((root(city1,i),root(city2,i)))
c=Counter(r)
for i in range(n):
  ans=c[r[i]]
  if i==n-1:
    print(ans)
  else:
    print(ans,end=' ')

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

int main() {
  const int M = 1000001;
  int n; cin >> n;
  map<int,int> A;
  int ans = 0;
  rep(i,n) {
    int a; cin >> a;
    A[a]++;
  }
  vector<int> d(M,0);
  for (auto a : A) {
    int x = a.first;
    int cnt = a.second;
    for (int i = x; i<=M; i+=x) {
      d[i] += cnt;
    }
  }
  for (auto a : A) {
    if (d[a.first] == 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 16428
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int a, b;
    cin >> a >> b;

    if(a==b) {
        rep(i, a) cout << b;
    } else {
        if(a > b) swap(a, b);
        rep(i, b) cout << a;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), even = 0;
		for(int i = 0; i < N; i++) {
			int A = sc.nextInt();
			if(A % 2 == 0) even++;
		}
		System.out.println((int)Math.pow(3, N) - (1 << even));
	}
}

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

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

  int n, k;
  string s;
  cin >> n >> k >> s;
  int score = 0;
  rep(i, 0, n - 1) {
    if (s[i] == s[i + 1]) score++;
  }

  int ans = min(score + 2 * k, n - 1);
  cout << ans << endl;
}


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

int LSearch(int A[],unsigned int q,int x){
  A[q] = x;
  for(int i = 0;;i++){
    if(A[i] == x)
      if(i != q)
        return 0;
      else
        return -1;
  }
}
int main(){
  unsigned int n,q;
  unsigned int counter = 0;
  int S[10000000],T;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> S[i];
  }
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> T;
    if(LSearch(S,n,T) == 0)
      counter++;
  }
  cout << counter << endl;
}




Measured memory_bytes: 3100
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;
int main()
{
	int n;
	cin >> n;
	map<int, int> mp;
	rep(i, n) {
		int a;
		cin >> a;
		mp[a-1] = i + 1;
	}
	rep(i, n) cout << mp[i]<<" ";
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> u(N - 1), v(N - 1);
    for (int i = 0; i < N - 1; i++)
    {
        cin >> u.at(i) >> v.at(i);
    }

    int64_t sum_v = 0;
    for (int i = 1; i <= N; i++)
    {
        sum_v += (int64_t)i * (N - i + 1);
    }

    int64_t sum_e = 0;
    for (int i = 0; i < N - 1; i++)
    {
        int vl = min(u.at(i), v.at(i)), vr = max(u.at(i), v.at(i));
        sum_e += (int64_t)vl * (N - vr + 1);
    }

    cout << sum_v - sum_e << endl;
    return 0;
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
#define lint long long
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define to_stirng to_string
using namespace std;

// cout << fixed << setprecision(12)

int main(){
  lint A,V,B,W,T;
  cin >> A >> V >> B >> W >> T;
  
  if(V<=W) cout << "NO";
  else{
    if(abs(A-B) <= (V-W)*T) cout << "YES";
    else cout << "NO";
  }
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

int main() {
  int32_t M, D;
  cin >> M >> D;
  int32_t d1, d2;
  uint32_t res = 0;

  for (uint32_t m = 1; m <= M; ++m) {
    for (uint32_t d = 1; d <= D; ++d) {
      d1 = d % 10;
      d2 = d / 10;
      if (d1 * d2 == m && d1 >= 2 && d2 >= 2) {
        res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  print(s);
}

Measured memory_bytes: 256