akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;

vvi edge;
vi prenum;
vi lowest;
vi parent;
int timer;

void dfs(int u, int prev) {
  prenum[u] = timer;
  lowest[u] = timer;
  timer += 1;

  for (auto v : edge[u]) {
    if (prenum[v] < 0) {
      parent[v] = u;
      dfs(v, u);
      lowest[u] = min(lowest[u], lowest[v]);
    } else if (v != prev) {
      lowest[u] = min(lowest[u], prenum[v]);
    }
  }
}

int main() {
  int v, e;
  cin >> v >> e;
  edge.resize(v);
  prenum.resize(v, -1);
  lowest.resize(v);
  parent.resize(v);
  rep (i, e) {
    int s, t;
    cin >> s >> t;
    edge[s].pb(t);
    edge[t].pb(s);
  }
  timer = 0;
  dfs(0, -1);

  set<vi> ans;
  FOR(i, 1, v) {
    if (prenum[parent[i]] < lowest[i]) {
      int mi = min(parent[i], i);
      int ma = max(parent[i], i);
      ans.insert({mi, ma});
    }
  }
  for (auto e : ans) {
    printf("%d %d\n", e[0], e[1]);
  }

  return 0;
}

Measured memory_bytes: 4700
#include <bits/stdc++.h>
using namespace std;
int main(){
int k,a,b;
cin >> k >> a >> b;
if((b/k)-(a/k) > 0 || k == 1||(k==a &&a==b)||a%k==0||b%k==0) cout << "OK" << endl;
else cout << "NG" << endl;


}

Measured memory_bytes: 3632
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String[] str = s.nextLine().split(" ");
		int H = Integer.parseInt(str[0]);
		int W = Integer.parseInt(str[1]);
		int[][] input = new int[W][H];
		for(int i=0 ; i<H ; i++) {
			String[] tmp = s.nextLine().split(" ");
			for(int j=0 ; j<W ; j++) {
				input[j][i] = Integer.parseInt(tmp[j]);
			}
		}
		System.out.println(solve(input));
	}

	public static int solve(int[][] input) {
		int[][] result = new int[input.length][input[0].length];
		for(int i=0 ; i<input.length ; i++) {
			if(input[i][0] == 0)
				result[i][0] = 1;
			else
				result[i][0] = 0;
		}
		for(int j=0 ; j<input[0].length ; j++) {
			if(input[0][j] == 0)
				result[0][j] = 1;
			else
				result[0][j] = 0;
		}

		for(int i=1 ; i<input.length ; i++) {
			for(int j=1 ; j<input[0].length ; j++) {
				if(input[i][j] == 0) {
					int min = Math.min(result[i-1][j], result[i][j-1]);
					min = Math.min(min, result[i-1][j-1]);
					result[i][j] = min + 1;
				}
				else
					result[i][j] = 0;
			}
		}
		int max = 0;
		for(int i=0 ; i<input.length ; i++) {
			for(int j=0 ; j<input[0].length ; j++) {
				max = Math.max(max, result[i][j]);
			}
		}
		return max*max;
	}

}

Measured memory_bytes: 102868
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    string S;cin>>S;
    ll N=S.size();
    ll R=N/2;
    ll cnt=0;
    REP(i,R){
        if(S[i]==S[N-1-i])continue;
        else cnt++;
    }
    cout<<cnt<<"\n";
}

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

int main(){
	int n;
	scanf("%d", &n);
	int d[n];
	for(int i=0; i<n; i++){
		scanf("%d", &d[i]);
	}
	
	int sum=0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			sum += d[i]*d[j];
		}
	}
	
	printf("%d\n", sum);
	
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
	    p(N*N*N);
    }
    public static <T> void p(T element) {
	System.out.println(element);
    }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22996
loop do
  n, k = gets.split.map(&:to_i)
  break if n == 0
  points =
    k.times.map do
      c, a, b = gets.split
      a = a.to_i; b = b.to_i
      case c
      when 'xy'
        [a, b, 0]
      when 'yz'
        [0, a, b]
      when 'xz'
        [a, 0, b]
      end
    end

  cross_points = []
  points.combination(2).each do |a, b|
    c = a.zip(b)
    if c.all?{ |p, q| !(p == 0 && q == 0) } && c.any?{ |p, q| p == q }
      cp = c.map{ |p, q| [p, q].max }
      cross_points << cp if cross_points.count(cp) < 2
    end
  end
  puts n * n * n - k * n + cross_points.size
end

Measured memory_bytes: 8688
#include<iostream>
#include<string>
#include<unordered_set>

using namespace std;

int n;
string s[100];
unordered_set<string> t;

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

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

	t.emplace(s[0]);
	for (int i = 1; i < n; i++) {
		if(t.count(s[i]) or s[i - 1].back() != s[i].front()){
			cout << "No" << '\n';
			return 0;
		}
		t.emplace(s[i]);
	}
	cout << "Yes" << '\n';
}


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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define f(n)                for (ll i=0;i<n;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define N                   100005
ll MOD=pow(10,9)+7;
ll INF=1ll<<60;

double dp[3000][3000];

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

    double p[n+1];
    rep(i,1,n+1)
    cin>>p[i];

    dp[1][0]=1-p[1];
    dp[1][1]=p[1];
    rep(i,2,n+1)
    {
        rep(j,0,i+1)
        {
            dp[i][j]=(dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i]);
        }
    }

    ll half=n/2;
    double ans=0;
    rep(i,half+1,n+1)
    {
        ans+=dp[n][i];
    }

    cout<<setprecision(11)<<ans<<endl;
}

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

int main(){
    
    ll a[2], b[2], ans = 11451419190;
    cin >> a[0] >> b[0];
    a[1] = -a[0];
    b[1] = -b[0];
    for(ll i = 0; i < 2; i++){
        for(ll j = 0; j < 2; j++){
            if(a[i] <= b[j]){
                ans = min(ans, b[j] - a[i] + i + j);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str1[] = new String[n];
        String str2[] = new String[n];
        
        for(i = 0; i < n; i++) {
        	str1[i] = sc.next();
        	str2[i] = str1[i];
        }
        
        outPut(bubble(str1, n), n);
        System.out.println("Stable");
        
        outPut(sellect(str2, n), n);
        for(i = 0; i < n; i++) {
        	if(str1[i] != str2[i]) {
        		System.out.println("Not stable");
        		return;
        	}
        }
        System.out.println("Stable");
	}
	
	//bubble sort
	public static String[] bubble(String[] a, int n) {
		int tmp;
		String stmp;
		int b[] = new int[n];
		for(int i = 0; i < n; i++) {
        	b[i] = Character.getNumericValue(a[i].charAt(1));
        }
		for(int i = 0; i < n-1; i++) {
			for(int j = n-1; j > 0; j--) {
				if(b[j] < b[j-1]) {
					tmp = b[j];
					b[j] = b[j-1];
					b[j-1] = tmp;
					stmp = a[j];
					a[j] = a[j-1];
					a[j-1] = stmp;
				}
			}
		}
		return a;
	}
	
	//sellection sort
	public static String[] sellect(String[] a, int n) {
		boolean flag = false;
		int tmp;
		String stmp;
		int[] b = new int[n];
		for(int i = 0; i < n; i++) {
        	b[i] = Character.getNumericValue(a[i].charAt(1));
        }
		for(int i = 0; i < n-1; i++){
			int minj = i;
			for(int j = i+1; j < n; j++) {
				if(b[j] < b[minj]) {
					minj = j;
					flag = true;
				}
			}
			if(flag) {
				tmp = b[i];
				b[i] = b[minj];
				b[minj] = tmp;
				stmp = a[i];
				a[i] = a[minj];
				a[minj] = stmp;
				flag = false;
				
			}
		}
		return a;
	}
	
	//output array
	public static void outPut(String[] a, int n) {
		for(int i = 0; i < n-1; i++) {
			System.out.print(a[i] + " ");
		}
		System.out.println(a[n-1]);
	}
}


Measured memory_bytes: 26264
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(void) {
    int64_t N;
    cin >> N;
    vector<int64_t> a(3*N);
    for(int64_t i=0; i<3*N; i++) {
        cin >> a[i];
    }

    priority_queue<int64_t, vector<int64_t>, greater<int64_t>> l;
    int64_t lsum = 0;
    for(int64_t i=0; i<N; i++) {
        l.push(a[i]);
        lsum += a[i];
    }
    vector<int64_t> lsumv(3*N);
    lsumv[N-1] = lsum;
    for(int64_t i=N; i<2*N; i++) {
        if(a[i] > l.top()) {
            lsumv[i] = lsumv[i-1] - l.top() + a[i];
            l.pop();
            l.push(a[i]);
        } else {
            lsumv[i] = lsumv[i-1]; 
        }
    }

    priority_queue<int64_t, vector<int64_t>, less<int64_t>> r;
    int64_t rsum = 0;
    for(int64_t i=2*N; i<3*N; i++) {
        r.push(a[i]);
        rsum += a[i];
    }
    vector<int64_t> rsumv(3*N);
    rsumv[2*N] = rsum;
    for(int64_t i=2*N-1; i>=N; i--) {
        if(a[i] < r.top()) {
            rsumv[i] = rsumv[i+1] - r.top() + a[i];
            r.pop();
            r.push(a[i]);
        } else {
            rsumv[i] = rsumv[i+1]; 
        }
    }

    int64_t ans = INT64_MIN;
    for(int64_t K=N; K<=2*N; K++)  {
        ans = max(ans, lsumv[K-1] - rsumv[K]);
    }

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


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

int main() {
  int N, M;
  cin >> N >> M;
  int allvote = 0;
  vector<int> point(N);
  for(int i=0; i<N; i++){
    cin >> point.at(i);
    allvote += point.at(i);
  }
  int count = 0;
  for(int i=0; i<N; i++){
    if(allvote%(4*M) != 0){
    	if(point.at(i) > allvote/(4*M)){
      	count ++;
    	}
    	if(count >= M){
      	cout << "Yes" << endl;
      	break;
    	} 
    	if((i == N-1)&&(count < M)){
      	cout << "No" << endl;
    	}
    } else {
      if(point.at(i) >= allvote/(4*M)){
      	count ++;
    	}
    	if(count >= M){
      	cout << "Yes" << endl;
      	break;
    	} 
    	if((i == N-1)&&(count < M)){
      	cout << "No" << endl;
        }
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char t[1000];
    gets(t);
    int n=0;
    int s=0;
    int e=0;
    int w=0;
    for(int i=0;i<strlen(t);i++){
        if(t[i]=='N'){
            n=1;
        }else if(t[i]=='S'){
            s=1;
        }else if(t[i]=='E'){
            e=1;
        }else if(t[i]=='W'){
            w=1;
        }
    }
    
    if((n-s)==0 && (w-e)==0){
        printf("Yes");   
    }else{
    
        printf("No"); 
    }
    
    
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, d; cin >> n >> d;
    if(n % (2*d + 1)){
        cout << n / (2*d + 1) + 1 << endl;
    }else{
        cout << n / (2*d + 1) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;

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

	cout << 6-a-b << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<math.h>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<unordered_map>
#include<set>
#include <algorithm>
#include <utility>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::pair;
using std::make_pair;
using std::priority_queue;

typedef unsigned long long ull;
typedef long long ll;

#define Prime1 1000000007
#define Prime2 9999973

#define INF 0x7fffffffffffffff

ull i, j, k, l, m, n;
ull H, W, Q;
ull a, b, c, x, y;
ull K, L, N, M;

int main()
{
	vector<ull> A;
	cin >> N;
	for(i=0;i<N;++i)
	{
		cin >> a;
		A.push_back(a);
	}
	std::sort(A.begin(), A.end());
	H = W = 0;
	auto itr = A.end() - 1;
	while (itr != A.begin())
	{
		if (*itr == *(itr - 1))
		{
			H = *itr;
			itr--;
			if(itr!=A.begin())itr--;
			break;
		}
		itr--;
	}
	if (H == 0)
	{
		cout << "0\n";
		return 0;
	}
	while (itr != A.begin())
	{
		if (*itr == *(itr - 1))
		{
			W = *itr;
			break;
		}
		itr--;
	}
	if (W == 0)
	{
		cout << "0\n";
	}
	else
	{
		cout << H*W << '\n';
	}
	return 0;
}


Measured memory_bytes: 1400
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    string s;
    cin >> s;
    if(s.substr(0,4) == "YAKI") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3032
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N):
    if i+1 == P[i]:
        if i+1 == N:
            P[i],P[i-1] = P[i-1],P[i]
        else:
            P[i],P[i+1] = P[i+1],P[i]
        ans += 1
print(ans)

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

typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N),B(N),C(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<N;i++){
        cin >> B[i];
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
    }

    sort(A.begin(),A.end());
    sort(C.begin(),C.end());

    ll ans=0;
    for(int i=0;i<N;i++){
        auto itr_upper = upper_bound(C.begin(),C.end(),B[i]);
        ll d_u = distance(itr_upper,C.end());
        auto itr_lower = lower_bound(A.begin(),A.end(),B[i]);
        ll d_l = distance(A.begin(),itr_lower);
        ans+= d_u * d_l;
    }

    cout << ans << endl;
    
    
}

Measured memory_bytes: 2560
import java.util.Scanner; 
public class Main { 
	public static void main(String... args) { 
		Scanner sc = new Scanner(System.in); 
		while(true) { 
			
			int n = sc.nextInt(); 
			int x = sc.nextInt(); 
			
			if(n == 0 && x == 0) break; 
			
			int count = 0;
			
			for(int a=1; a<=n; a++){
				for (int b=a+1; b<=n; b++) {
					for (int c=b+1; c<=n; c++) {
						if (a+b+c == x) {
							count++;
						}
					}
				}
			}
			
			
			
			System.out.println(count); 
		} 
	} 
}


Measured memory_bytes: 26616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	ll gcd(int a, int b) {
		std::cout << "a" << std::endl;
		if (b == 0) return a;
		return gcd(b, a % b);
	}

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

int main() {

	while (true) {
		int h, w;
		std::cin >> h >> w;
		if (h == 0 && w == 0) break;
	
		// 100 * 100 * 1000
		int value = h * h + w * w;
		int ans_h = 1;
		int ans_w = 1;
		int min_value = inf;
		bool end = false;
		Rep(height, 1, 151) {
			Rep(width, height + 1, 151) {
				int tmp = height * height + width * width;
				if (value == tmp) {
					if (h < height) {
						ans_h = height;
						ans_w = width;
						end = true;
						break;
					}
				}
				if (tmp < min_value && value < tmp) {
					min_value = tmp;
					ans_h = height;
					ans_w = width;
				}
			}
			if (end) break;
		}
		std::cout << ans_h << " " << ans_w << std::endl;
	}

	return 0;
}



Measured memory_bytes: 3072
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* It does not matter how slowly you go as long as you do not stop.*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1005;


int32_t main(){
    FAST;

    int a, b;
    cin >> a >> b;
    cout << ((a*b) % 2 == 0 ? "Even" : "Odd") << endl;

    return 0;
}




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

int a[100010];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++){
		scanf("%d", &a[i]);
	}
	sort(a, a + m);
	vector <int> all;
	for (int i = 1; i < m; i++){
		all.push_back(a[i] - a[i - 1]);
	}
	sort(all.begin(), all.end());
	long long ans = 0;
	for (int i = 0; i < m - n; i++){
		ans += all[i];
	}
	printf("%I64d\n", ans);
	return 0;
}


Measured memory_bytes: 1276
# Problem https://atcoder.jp/contests/abc113/tasks/abc113_b
# Python 1st Try
import sys


def solver(allnum, maxtemp, targettemp, heightplace):

    answer = 0
    mindiff = 100000000
    for j in range(0, allnum):
        difftemp = abs(targettemp - (maxtemp-heightplace[j]*0.006))
        if difftemp < mindiff:
            mindiff = difftemp
            answer = j
    return answer+1


if __name__ == "__main__":
    N = list(map(int, sys.stdin.readline().rsplit()))
    SLINE = list(map(float, sys.stdin.readline().split()))
    HI = list(map(float, sys.stdin.readline().split()))
    print(solver(N[0], SLINE[0], SLINE[1], HI))


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (ll)(n); ++i)
#define rrep(i, j, n) for (int i = (int)(n)-1; j <= i; --i)

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& a) {
  os << "{";
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? "," : "") << a[i];
  return os << "}";
}

[[maybe_unused]] constexpr ll MOD = 1000000007;
[[maybe_unused]] constexpr int INF = 0x3f3f3f3f;
[[maybe_unused]] constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ll n, x, m;
  cin >> n >> x >> m;
  vector<bool> used(m * 2);
  vector<ll> one_cycle;

  int start = 0;
  ll now = x;
  rep(i, 0, n) {
    used[now] = true;
    one_cycle.push_back(now);
    now = now * now % m;
    if (used[now]) {
      rep(j, 0, one_cycle.size()) if (one_cycle[j] == now) {
        start = j;
        break;
      }
      break;
    }
  }

  ll s1 = 0, s2 = 0, loop = (int)one_cycle.size() - start;
  rep(i, 0, start) s1 += one_cycle[i];
  rep(i, start, one_cycle.size()) s2 += one_cycle[i];
  ll ans = s1 + (n - start) / loop * s2;
  rep(i, 0, (n - start) % loop) {
    ans += now;
    now = now * now % m;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3900
N, *A = [int(_) for _ in open(0).read().split()]
win_lose = {i: set() for i in range(1, N + 1)}
for lose, win in enumerate(A):
    win_lose[win].add(lose + 2)
s1 = [1]
s2 = []
while s1:
    a = s1.pop()
    s2 += [a]
    for b in win_lose[a]:
        s1 += [b]
dp = [0] * (N + 1)
for x in s2[::-1]:
    if win_lose[x] == set():
        dp[x] = 0
    else:
        dp[x] = max(
            i + v + 1
            for i, v in enumerate(sorted(dp[y] for y in win_lose[x])[::-1]))
print(dp[1])


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

int main(){
	int A, B, M, i, ans = 1000000000;
	scanf("%d%d%d", &A, &B, &M);
	vector<int> a(A), b(B);
	for(i = 0; i < A; i++){
		scanf("%d", &a[i]);
	}
	for(i = 0; i < B; i++){
		scanf("%d", &b[i]);
	}
	for(i = 0; i < M; i++){
		int x, y, c;
		scanf("%d%d%d", &x, &y, &c);
		x--;
		y--;
		ans = min(ans, a[x] + b[y] - c);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	printf("%d\n", min(ans, a[0] + b[0]));
	return 0;
}

Measured memory_bytes: 1024
//copied from PG111002(UVa10054)
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstring>
 
#define hi(_x) ((_x)>>16)
#define lo(_x) ((_x)&0xffff)
using namespace std;
#define rotate(v, index) rotate((v).begin(), (v).begin()+(index), (v).end())
 
inline int unite(vector<int> &u, vector<vector<int>*> &array){
  int _array, _u, _each;
  while(array.size()){
    for(_array=0; _array<array.size(); _array++){//今まで作ったeuler閉路すべてに対しuと結合できるかどうか調べる
      vector<int> each = *(array[_array]); //eachはeuler閉路を構成すると仮定する
      for(_u=0; _u<u.size(); _u++){
        for(_each=0; _each<each.size(); _each++){
          if(lo(u[_u])==hi(each[_each])){
            if(_each)rotate(each,_each); //each[_each]が先頭に来るよう頭だし
            u.insert(u.begin()+_u+1,each.begin(),each.end());
            delete array[_array];
            array.erase(array.begin()+_array);
            goto next;
          }
        }
      }
    }
    //fail
    return 0;
    next:
    /*continue*/;
  }//while
  return 1;
}
 
inline int sort(vector<int>&s,vector<int>&v){
  int x=hi(v[0]), y=lo(v[0]), i, a=0;
  v.erase(v.begin());
  s.push_back((x<<16)+y);
  while(1){
    for(i=0; i<v.size(); i++){
      if(lo(s[a])==hi(v[i])/*||lo(s[a])==lo(v[i])*/)goto in;//break;
    }
    /*if(i==v.size())*/break;
in:
    x=hi(v[i]), y=lo(v[i]);
    v.erase(v.begin()+i);
    //if(lo(s[a])==y)swap(x,y);
    s.push_back((x<<16)+y);
    a++;
  }//while
  return hi(s[0])==lo(s[a]);
}
 
char s[99];
int main(){
  int i=0, k;
  int n, l, x, y;
  vector<int> vorig;
  vector<vector<int>*> varray;
  vector<int> vunite;
 
  //scanf("%d",&n);
  //for(;i<n;i++){
  for(;;){
    //if(i) printf("\n");
    //printf("Case #%d\n",i+1);
    scanf("%d",&l);
    if(!l)return 0;
 
    for(k=0;k<l;k++){
      //scanf("%d %d",&x, &y);
      scanf("%s",s);
      x=s[0]-96,y=s[strlen(s)-1]-96;
      vorig.push_back((x<<16)+y);
    }
 
    while(vorig.size()){
      vector<int> *p = new vector<int>;
      if(!sort(*p,vorig))goto fail;
      varray.push_back(p);
    }
 
    vunite = *(varray[0]);
    delete varray[0];
    varray.erase(varray.begin());
    if(!unite(vunite,varray))goto fail;
 
    while(vunite.size()){
      //printf("%d %d\n",hi(vunite[0]),lo(vunite[0]));
      vunite.erase(vunite.begin());
    }
    puts("OK");
    continue;
 
fail:
    while(varray.size()){
      delete varray[0];
      varray.erase(varray.begin());
    }
    //puts("some beads may be lost");
    puts("NG");
    vorig.clear();
    vunite.clear();
  }//for
}//main

Measured memory_bytes: 1296
#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

template<typename ISTREAM>
void readGraphList(ISTREAM& cin, vector< vector<int> >& graphList) {
	size_t n;
	cin >> n;
	graphList = vector< vector<int> >(n);
	for (size_t i = 0; i != n; ++i) {
		size_t u;
		size_t k;
		cin >> u;
		cin >> k;
		vector<int>& v = graphList.at(u - 1);
		v.resize(k);
		for (size_t j = 0; j != k; ++j) {
			cin >> v.at(j);
			v.at(j)--;
		}
	}
}
#if 1
void widthSearch(const vector<vector<int>>& graphList) {
	const size_t n = graphList.size();
	queue<int> nodeQueue;
	vector<int> distanceList(n, -1);
	nodeQueue.push(0);
	while (!nodeQueue.empty()) {
		const int id = nodeQueue.front();
		int& currentNodeDistance = distanceList.at(id);
		++currentNodeDistance;
		const vector<int>& adjList = graphList.at(id);
		for (const auto& adjID : adjList) {
			int& adjDistance = distanceList.at(adjID);
			if (adjDistance != -1)continue;
			nodeQueue.push(adjID);
			adjDistance = currentNodeDistance;
		}
		nodeQueue.pop();
	}
	for (int i = 0; i != n; ++i) {
		cout << i + 1 << " " << distanceList.at(i) << endl;
	}
}
#endif

template<typename T>
void execute(T& cin) {
	vector< vector<int> > graphList;
	readGraphList(cin, graphList);
	widthSearch(graphList);
}

int main()
{
	execute(cin);

	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

string S, T;
int Answer = (1 << 30);

int Diff(string A, string B) {
	int cnt = 0;
	for (int i = 0; i < A.size(); i++) {
		if (A[i] != B[i]) cnt++;
	}
	return cnt;
}

int main() {
	cin >> S >> T;
	for (int i = 0; i <= S.size() - T.size(); i++) {
		string U = S.substr(i, T.size());
		Answer = min(Answer, Diff(U, T));
	}
	cout << Answer << endl;
	return 0;
}

Measured memory_bytes: 3624
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<u32>();
    let d = v[0];
    let n = v[1];

    let mut ans = if n == 100 { 101 } else { n };
    for _ in 0..d {
        ans *= 100;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
def solve(a, b, c, x, y):
    if 2 * c >= a + b:
        return a * x + b * y
    m = min(x, y)
    return 2 * c * m + min(a, 2 * c) * (x - m) + min(b, 2 * c) * (y - m)


def main():
    a, b, c, x, y = map(int, input().split())
    print(solve(a, b, c, x, y))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<int>temp[205];
vector<vector<int> >adj;
int mx=0;
void dfs(int ver,int pr,int x)
{	
	mx=max(mx,x);
	for(auto i:adj[ver])
	{
		if(i!=pr)
			dfs(i,ver,x+1);
	}
}

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif  

	int n;
	cin>>n;
	adj.resize(n+1);
	pair<int,int> a[n+1];
	int pp[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].first;
		pp[i]=a[i].first;
		a[i].second=i;
		temp[a[i].first].push_back(i);
	}
	sort(a+1,a+n+1);
	int x,y;
	x=1,y=2;
	vector<pair<int,int>> ans;

	if(a[1].first==a[2].first)
	{
		ans.push_back({a[1].second,a[2].second});
		x=a[1].second;
		y=a[2].second;
		for(int i=a[1].first+1;i<=n;i++)
		{
			if(!temp[i].empty())
			{
				ans.push_back({temp[i].back(),y});
				y=temp[i].back();
				temp[i].pop_back();
				int z=1;
				while (!temp[i].empty())
				{
					z=temp[i].back();
					ans.push_back({x,z});
					temp[i].pop_back();
				}
				x=z;
			}
		}
	}
	else if(n>2)
	{
		for(auto i:temp[a[1].first+1])
		{
			ans.push_back({a[1].second,i});	
			y=x;
			x=i;					
		}

		for(int i=a[1].first+2;i<=n;i++)
		{
			if(!temp[i].empty())
			{
				ans.push_back({temp[i].back(),y});
				y=temp[i].back();
				temp[i].pop_back();
				int z=1;
				while (!temp[i].empty())
				{
					z=temp[i].back();
					ans.push_back({x,z});
					temp[i].pop_back();
				}
				x=z;
			}
		}		
	}

	for(auto i:ans)
	{
		adj[i.first].push_back(i.second);
		adj[i.second].push_back(i.first);
	}	

	for(int i=1;i<=n;i++)
	{
		mx=0;
		dfs(i,0,0);
		if(pp[i]!=mx)
		{
			cout<<"Impossible";
			return 0;
		}
	}
	cout<<"Possible";
}


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

#define rep(i, x, n) for(int i=(x);i<(n);i++)
#define reps(i, x, n) for(int i=(x);i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
//八方向を見るのに使うと便利(楽)
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[2][105] = {};
  rep(i, 0, 2){
    reps(j, 1, n){
      cin >> a[i][j];
      a[i][j] += a[i][j - 1];
    }
  }
  int ans = 0;
  reps(i, 1, n){
    ans = max(ans, a[0][i] + (a[1][n] - a[1][i - 1]));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3636
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.linalg import spsolve

N = int(input())
b = np.array(input().split()).astype(int)

rows = np.concatenate([np.arange(N), np.arange(N)])
cols = np.concatenate([np.arange(N), np.arange(1,N+1) % N])

A = csr_matrix(([1] * (2*N), (rows, cols)), (N,N))

x = (spsolve(A, b) * 2).astype(int)

print(*x)

Measured memory_bytes: 65236
#include <cstdio>
int main()
{
    int count[26] = {};
    char s[1800];
    while (fgets(s, 1800, stdin) != NULL)
    {
        for (int i = 0; s[i] != '\0'; i++)
        {
            if (s[i] >= 'A' && s[i] <= 'Z')
            {
                count[s[i] - 'A']++;
            }
            if (s[i] >= 'a' && s[i] <= 'z')
            {
                count[s[i] - 'a']++;
            }
        }
    }
    for (int i = 0; i < 26; i++)
    {
        printf("%c : %d\n", 'a' + i, count[i]);
    }
}


Measured memory_bytes: 2704
#include<stdio.h>
int main(void){
	char s[3];
	float n,sum=0,x;
	for(scanf("%f",&n);n;n--){
		scanf("%f %s",&x,s);
		if(s[0]=='J'){
			sum+=x;
		}
		else{
			sum+=x*380000;
		}
	}
	printf("%f",sum);
	return 0;
}

Measured memory_bytes: 128
program AGC012A
    implicit none
    integer(8)::N,ans,i
    integer(8),allocatable,dimension(:)::A
    read*,N
    allocate(A(3*N))
    read*,A
    A=iqsort(A)
    ans=0

    do i=1,N
        ans=ans+A(3*N-2*i+1)
    end do
    print'(i0)',ans
contains
    recursive function iqsort(ix) result(ires)
      integer(8), allocatable :: ires(:)
      integer(8), intent(in)  :: ix(:)
      integer :: k
      if (size(ix) <= 1) then 
        ires = ix
      else  
        k = ix(size(ix) / 2)
        ires = [iqsort(pack(ix, ix < k)), pack(ix, ix == k), iqsort(pack(ix, ix > k))] 
      end if
    end function iqsort
end program AGC012A

Measured memory_bytes: 12864
function main(input) {
  var count = 0
  for(var i = 1;i <= input;i++){
    for(var j = 1;j <= input;j++){
     for(var k = 1;k <= input;k++){
        count+=gcd(i,j,k);   
  }
  }
  }
      console.log(count);
}

function gcd() {
    var f = (a, b) => b ? f(b, a % b) : a
    var ans = arguments[0]
    for (var i = 1; i < arguments.length; i++) {
        ans = f(ans, arguments[i]); 
    }
    return ans 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 34672
n,d = map(int,input().split())
k = d + 1
ans = 0
isnegetive = False
while isnegetive == False:
  ans += 1
  x = n - (k + d)
  #print(n)
  k = k + d + 1 + d
  #print(k)
  if x <= 0:
    #print(i)
    isnegetive = True
  
print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if (c % gcd(a, b))
    cout << "NO\n";
  else
    cout << "YES\n";
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
if N >= M:
  print(0)
else:
  Y = []
  for i in range(M-1):
    Y.append(X[i+1] - X[i])
  Y.sort(reverse=True)
  print(X[-1] - X[0] - sum(Y[:N-1]))

Measured memory_bytes: 91288
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main (void){
    int L;
    int N;
    char S[10000];
    int MUL[128]={0};
    int NUM[10000]={0};
    int g=0;
    int ans = 0;
    scanf("%d",&N);
    scanf("%s",S);

    for (int i = 0; i < N; i+=2)
    {
        MUL[S[i]]++;
    }
    for (int i = 0; i < 128; ++i)
    {
        NUM[MUL[i]]++;

    }

    if(NUM[1]>0) ans+=NUM[1]*2;

     for (int i = 2; i < N; ++i)
    {
        if(NUM[i]>=2) ans+=NUM[i]*2+4;
        else if(NUM[i]>=1) ans+=4;
 }
    ans--;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1248
/*
 * ABC092_A.cpp
 *
 *  Created on: May 21, 2018
 *      Author: 13743
 */
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}



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

	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int ans = min(A,B) + min(C,D);
	cout << ans << endl;
}






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

int main(){
  string S;cin>>S;
  for(int i=0;i<3;i++){
    if(S[i]=='1') {
      S[i]='9';
    }
    else S[i]='1';
    }
	cout<<S<<endl;
}

Measured memory_bytes: 3620
import sys
f = sys.stdin

def take2(iterable):
    i = iter(iterable)
    while True:
        yield next(i), next(i)
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
def in_triangle(a, b, c, p):
    v1 = cross(a - b, b - p)
    v2 = cross(b - c, c - p)
    v3 = cross(c - a, a - p)
    return 0 < v1 * v2 and 0 < v2 * v3

for line in f:
    a, b, c, p = [x + y *1j for x, y in take2(map(float, line.split()))]
    print('YES' if in_triangle(a,b,c,p) else 'NO')

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

int main()
{
	int x,a,b;
	cin >> x >> a >> b;
	if(abs(x-a) < abs(x-b)){
		cout << "A\n";
	}else{
		cout << "B\n";
	}

	return 0;
}


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

int search(int array[], int length, int key)
{
    int i = 0;
    array[length] = key;
    while (array[i] != key)
    {
        i++;
    }
    return i != length;
}

int main()
{
    int baseArrayNum;
    cin >> baseArrayNum;
    int baseArray[baseArrayNum + 1];

    for (int i = 0; i < baseArrayNum; i++)
    {
        cin >> baseArray[i];
    }

    int targetArrayNum;
    cin >> targetArrayNum;
    int targetArray[targetArrayNum];

    for (int i = 0; i < targetArrayNum; i++)
    {
        cin >> targetArray[i];
    }

    int counter = 0;
    for (int i = 0; i < targetArrayNum; i++)
    {
        int key = targetArray[i];
        if (search(baseArray, baseArrayNum, key))
            counter++;
    }

    cout << counter << endl;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std; 

int main()
{
    ll n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;
    string t;
    cin>>t;
    ll ans=0;
    char c[n];
    memset(c,'t',sizeof(c));
    for(ll i=0;i<k;i++)
    {
        if(t[i]=='r')
        {
            ans+=p;
            c[i]='p';
        }
        else if(t[i]=='p')
        {
            ans+=s;
            c[i]='s';
        }
        else if(t[i]=='s')
        {
            ans+=r;
            c[i]='r';
        }
    }
    for(ll i=k;i<n;i++)
    {
        if(t[i]=='r'&&c[i-k]!='p')
        {
            ans+=p;
            c[i]='p';
        }
        else if(t[i]=='p'&&c[i-k]!='s')
        {
            ans+=s;
            c[i]='s';
        }
        else if(t[i]=='s'&&c[i-k]!='r')
        {
            ans+=r;
            c[i]='r';
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int a, b;
	cin >> a >> b;
	if ((a + b) & 1) cout << "IMPOSSIBLE" << endl;
	else cout << (a + b) / 2 << endl;
}


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

using namespace std;

int n, k;
int a[212345];
int cnt[212345];

int main() {
                                               

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

	sort(a + 1, a + n + 1);
	if(a[1] * 2 < a[n]) return cout << "Impossible", 0;

	if(cnt[1]>1&&n>2)return cout << "Impossible", 0;
	if(a[n]>n-1) return cout << "Impossible", 0;
	if(a[n]==n-1 && cnt[a[n]]>2)return cout << "Impossible", 0;
	for(int i = n; i <= n; i++)
		if(a[i]!=1&&cnt[a[i]]<2)return cout << "Impossible", 0;

	for(int i = a[n]/2+1; i <= a[n]; i++)
		if(cnt[i]<=1)return cout << "Impossible", 0;
	for(int i = 1; i < (a[n]+1)/ 2; i++)
		if(cnt[i])return cout << "Impossible",0;
	if(a[n]%2)
		if(cnt[a[n]/2+1]!=2)return cout << "Impossible", 0;
	if(a[n]%2==0)
		if(cnt[a[n]/2]!=1)return cout << "Impossible",0;
	if(a[1] == a[n] && !(n==2&&a[1]==1)) return cout << "Impossible", 0;
	cout << "Possible";
	return 0;
}




Measured memory_bytes: 256
n = gets.to_i
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)

sum = Array.new(3,0)
d = Array.new(3,0)
values = Array.new(3,0)
(1..3).each do |a|
    (0..(x.size-1)).each do |i|
        val = (x[i] - y[i]).abs
        values[a-1] = val if values[a-1] < val
        sum[a-1] += val**a
    end
    puts d[a-1] = sum[a-1]**(1.0/a)
end

p values.max


Measured memory_bytes: 8908
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
ll ck[100000];
int main()
{
  int t;
  t=1;
  //cin >> t;
  while (t--)
  {
      ll n,d,i,j,x,y,mx=INT_MIN,mn=INT_MAX;
      cin>>n>>d;
       FOR(i,1,d)
       {
        cin>>x>>y;
        mx=max(mx,x);
        mn=min(mn,y);
       }
       cout<<max(ll(0),(mn-mx)+1)<<endl;
  }
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#define ll long long
using namespace std;
ll N, X, a[55], p[55];

ll f(ll N, ll X) {
  if (N == 0)
    return X <= 0 ? 0 : 1;
  else if (X <= a[N - 1] + 1)
    return f(N - 1, X - 1);
  else
    return p[N - 1] + 1 + f(N - 1, X - a[N - 1] - 2);
}

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

  a[0] = 1;
  p[0] = 1;
  for (int i = 1; i < N + 1; i++) {
    a[i] = 2 * a[i - 1] + 3;
    p[i] = 2 * p[i - 1] + 1;
  }

  cout << f(N, X) << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#define loop(i,start,stop) for(int i = start; i < stop; i++)
#define rloop(j,start,stop) for(int j = start; j >= stop; j--)
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;


int M;
int main() {
        cin >> M;
        cout << 48 - M;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
unordered_map<ll, int>cnt;
int g2;
ll calc (int *a) {
	ll ans = 0; g2 = 0;
	for (int i = 0; i < 4; ++i) {
		ll tmp = 0;
		for (int j = 0; j < 4; ++j) tmp = tmp << 10 | a[(i + j) & 3];
		if (tmp > ans) ans = tmp, g2 = 1;
		else if (tmp == ans) ++g2;
	}
	return ans;
}

const int N = 404;

int p[N][4], n, tt[4];
ll a[4], ans, v;

int main () {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 4; ++j) scanf("%d", &p[i][j]), ++p[i][j];
		++cnt[calc(p[i])];
	}
	for (int i = 0; i < n; ++i) {
		
		for (int j = i + 1; j < n; ++j) {
			
			--cnt[calc(p[i])]; --cnt[calc(p[j])];
			
			for (int k = 0; k < 4; ++k) {
				
				v = 1;
				for (int t = 0; t < 4; ++t) {
					tt[0] = p[i][(t + 1) & 3];
					tt[1] = p[i][t];
					tt[2] = p[j][(k + 5 - t) & 3];
					tt[3] = p[j][(k - t + 4) & 3];
					a[t] = calc(tt);
					v *= g2;
				}
				
				for (int t = 0; t < 4; ++t) v *= cnt[a[t]]--;
				
				for (int t = 0; t < 4; ++t) ++cnt[a[t]];
				
				ans += v;
				
			}
			
			++cnt[calc(p[i])]; ++cnt[calc(p[j])];
		}
	}
	printf("%lld\n", ans / 3);
	return 0;
}

Measured memory_bytes: 58384