akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (b) - 1; (i) >= (a); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    ll x;
    cin >> x;
    pf(lcm(x, 360ll) / x);
    return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
int main(){
  long long int decide=0,i,v,r,w,dif,b,a,x,y,mod=1000000007,ans,dif2,fac[1000010],finv[1000010],inv[1000010];
  scanf("%lld %lld\n",&x,&y);
  if(x>y){
    dif=x-y;
    v=dif;
    a=x-2*dif,b=y-dif;
    if(a>=0 && a==b && a%3==0){
      dif2=a/3;
    }
    else{
      printf("0\n");
      decide=1;
    }
  }
  else{
    dif=y-x;
    v=dif;
    a=x-dif,b=y-2*dif;
    if(a>=0 && a==b && a%3==0){
      dif2=a/3;
    }
    else{
      printf("0\n");
      decide=1;
    }
  }
    v=v+2*dif2;
    r=dif2;
    fac[0]=1,fac[1]=1;
    finv[0]=1,finv[1]=1;
    inv[1]=1;
    for(i=2;i<=666666;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
    }
    ans=fac[v]*(finv[r]*finv[v-r]%mod)%mod;
  if(decide==0){
    printf("%lld\n",ans);
  }
  return 0;
}

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

typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;

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

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

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

  vector<bool> h(N+1, true);
  for(int i = 0; i < M; i++) {
    int a;cin >> a;
    h.at(a) = false;
  }

  vector<int> dp(N+1, 0);
  dp[0] = 1;
  if(h.at(1)) dp[1] = 1;
  for(int i = 2; i <= N; i++) {
    if(h.at(i-1)) dp[i] += dp[i-1];
    if(h.at(i-2)) dp[i] += dp[i-2];
    dp[i] %= MOD;
  }

  cout << dp[N] << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int main(void)
{
	ll N, M;
	cin >> N >> M;

	if (N == 1 && M == 1) {
		cout << 1 << endl;
	}
	else if (N == 1 || M == 1) {
		cout << max(N, M) - 2 << endl;
	}
	else {
		cout << (N - 2) * (M - 2) << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef vector<int> VI;
using namespace std;
const int NMAX=806;
const int INF=1000000666;
const LL INFLL=1000000000000666;
const LL maxv=100000;
const long double PI = acos(-1.0);
const int MAXT = 200000;

int A[1005];
int n;

int l[NMAX], r[NMAX];
vector<int> G[NMAX];
bool viz[NMAX];
int lf,rs;
 
bool dfs(int v)
{
    if(viz[v])
        return 0;
    viz[v]=1;
    for(auto w:G[v])
        if(l[w] == 0 || dfs(l[w]))
        {
            l[w]=v;
            r[v]=w;
            return 1;
        }
    return 0;
}


bool isprime(int x){
  int i = 2;
  int q = 1;
  if(x == 1){
    q = 0;
  }
  while(i*i <= x){
    if((x%i) == 0){
      q=0; 
    }
    i++;
  }
  return q;
}

void solve(){
  cin>>n;
  for(int i=1; i<=n; ++i){
    cin>>A[i];
  }
  vector<int> df;
  for(int i=1; i<=n; ++i){
    if(A[i] - A[i-1] > 1 || i==1){
      df.push_back(A[i]);
    }
    if(A[i+1] - A[i] > 1 || i==n){
      df.push_back(A[i] + 1);
    }
  }
  //sort(df.begin(), df.end());
  vector<int> lft, rht;

  for(auto el: df){
    //cout<<el<<" ";
    if(el % 2){
      rht.push_back(el);
    }
    else{
      lft.push_back(el);
    }
  }
  lf = lft.size();
  for(int i=0; i<lft.size(); ++i){
    for(int j=0; j<rht.size(); ++j){
      if(isprime(abs(lft[i] - rht[j])))
      {
        G[i+1].push_back(j+lf+1);
      }
    }
  }
  bool q=1;
  while(q)
  {
      q=0;
      memset(viz, 0, sizeof(viz));
      for(int i=1; i<=lf; ++i)
      {
          if(r[i]==0 && dfs(i))
          {
              q=1;
              rs++;
          }
      }
  }
  int a = lf - rs, b = rht.size() - rs;
  cout<<rs + 2*(a/2) + 2*(b/2) + 3*(a%2)<<"\n";
  

}


int main()
{
    // Tic
    //clock_t t=clock();
    cout<<setprecision(10)<<fixed;
    ios_base::sync_with_stdio(0);

    //freopen("simetrii.in", "rt", stdin);
    //freopen("simetrii.out", "wt", stdout);

    solve();

    //Toc
    //t=clock()-t;
    //printf ("It took me %d clicks (%f seconds).\n",t,((float)t)/CLOCKS_PER_SEC);
    return 0;
}


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

#define llong long long 
#define xx first
#define yy second
#define ii pair<int, int>
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = - 1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i++ < n; )

#define maxn 101010
int n;
llong a[maxn];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n;
  rep(i, n) cin >> a[i];
  llong l = 2, h = 2;
  for (int i = n; i--; ) {
    llong u = a[i];
    llong mi = (l + u - 1) / u * u;
    llong ma = h / u * u + u - 1;
    if (mi > ma) {
      cout << -1;
      exit(0);
    }
    l = mi;
    h = ma;
  }
  cout << l << ' ' << h;

  return 0;
}


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

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

  	if(a==b && c!=b) cout << "Yes" << endl;
  	else if(b==c && a!=c) cout << "Yes" << endl;
  	else if(a==c && c!=b) cout << "Yes" << endl;
 	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    ll N,D;cin >> N >> D;
    vector<PL> C(N);
    rep(i,N) cin >> C[i].first >> C[i].second;
    int ans = 0;
    rep(i,N) {
       ll x = C[i].first,y = C[i].second;
       if (x*x + y*y <= D*D) {
           ++ans;
       }
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

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

    int taro = 0, hanako = 0;

    for (int i = 0; i < n; i++) {
        string animal1, animal2;
        cin >> animal1 >> animal2;

        if (animal1 > animal2) taro += 3;
        else if (animal1 < animal2) hanako += 3;
        else {
            taro++;
            hanako++;
        }
    }

    cout << taro << ' ' << hanako << endl;
}


Measured memory_bytes: 3164
N,M=list(map(int,input().split()))
ans=0
min_r=sum(range(M))
max_r=sum(range(N-M+1,N+1))
ans+=max_r-min_r+1
for i in range(M,N+1):
   max_r+=N-i
   min_r+=i
   ans+=max_r-min_r+1
print(ans%(10**9+7))

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3001;
ll dp[N][N][2], a[N];
ll calc(int s, int e, int t) {
    if(dp[s][e][t]) return dp[s][e][t];
    if(s == e) {
        dp[s][e][0] = a[s]; 
        dp[s][e][1] = -a[s];
        return dp[s][e][t];
    }
    if(s > e)
        return 0;
    if(t) 
        dp[s][e][t] = min(-a[s]+calc(s+1,e,t^1),-a[e]+calc(s,e-1,t^1));
    else 
        dp[s][e][t] = max(a[s]+calc(s+1,e,t^1),a[e]+calc(s,e-1,t^1));
    return dp[s][e][t];
}
int main() {
    int n; cin>>n; 
    for(int i = 1; i <= n; ++i) cin>>a[i];
    cout<<calc(1,n,0)<<"\n";
}

Measured memory_bytes: 139776
#include <stdio.h>
 
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a >= b) {
    for (int i = 0; i < a; i++) {
      printf("%d", b);
    } 
  } else {
    for (int i = 0; i < b; i++) {
      printf("%d", a);
    } 
  }
  return 0;
}

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

int main(){
    int H, N;
    cin >> H >> N;
    vector<int> dp(H+1, 1e9+7);
    dp[0] = 0;
    rep(i,N){
        int a, b;
        cin >> a >> b;
        rep(j, H+1) dp[min(j+a,H)] = min(dp[min(j+a,H)], dp[j]+b);
    }
    cout << dp[H] << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
n=104730;a=list(range(n));a[:2]=0,0
for i in range(2,323):
 a[i*2::i]=[0]*len(a[i*2::i])
p=list(itertools.compress(range(n),a))
for e in iter(input,'0'):print(sum(p[:int(e)]))


Measured memory_bytes: 10460
from collections import deque
n = int(input())
M = [[0]*n for _ in range(n)]
d = [-1]*n
st = [0]*n
for _ in range(n):
    i = [int(i) for i in input().split()]
    u = i[0]
    k = i[1]
    V = i[2:]
    for v in V: M[u-1][v-1] = 1

def bfs(s):
    Q = deque()
    Q.append(s)
    st[s] = 1
    d[s] = 0
    while Q:
        u = Q.popleft()
        for v in range(n):
            if M[u][v] and st[v] == 0:
                st[v] = 1
                Q.append(v)
                d[v] = d[u]+1
        st[u] = 2
    return

bfs(0)
for i in range(n): print(i+1,d[i])


Measured memory_bytes: 6100
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    for(int i=max(a,b);i>min(a,b);i--) {
        if(i==c){cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
a = input().split()
n = int(a[0])
m = int(a[1])
qq = int(a[2])

x = [[0] * n for _ in range(n)]

for _ in range(m):
    a = input().split()
    x[int(a[0]) - 1][int(a[1]) - 1] += 1

for i in range(n):
    for j in range(1, n):
        x[i][j] += x[i][j - 1]

for i in range(1, n):
    for j in range(n):
        x[i][j] += x[i - 1][j]

for _ in range(qq):
    r = 0
    a = input().split()
    p = int(a[0])
    q = int(a[1])

    if 0 < q:
        r += x[q - 1][q - 1]

    if 0 < q and 1 < p:
        r -= x[q - 1][p - 2] + x[p - 2][q - 1]

    if 1 < p:
        r += x[p - 2][p - 2]

    print(r)


Measured memory_bytes: 13392
#include<stdio.h>
#include<stdlib.h>
int main(){
	int i, x;
	x = 1;
	srand(x);
	for (i = 1;i<=10000 ; i++) {
		scanf("%d", &x);
		if (x == 0){
			break;
		}
		printf("Case %d: %d\n", i,x);

		
	}




	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n;
    cin >> n;

    int i = 1;
    for(; i<=9; i++) {
        if (n <= i*111 ) break;
    }

    cout << i * 111 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        String[][] s = new String[N][W];
        for (int i=0; i<N; i++) {
            String row = sc.next();
            String[] cols = row.split("");
            for (int j=0; j<cols.length; j++) {
                s[i][j] = cols[j];
            }
        }
        String[][] t = new String[N][W];
        Integer[] dx = new Integer[]{0, 1, 0, -1, 1, 1, -1, -1};
        Integer[] dy = new Integer[]{1, 0, -1, 0, 1, -1, 1, -1};
        for (int i=0; i<N; i++) {
            for (int j = 0; j < W; j++) {
                if ("#".equals(s[i][j])) {
                    t[i][j] = "#";
                } else {
                    int cnt = 0;
                    for (int d=0; d<8; d++) {
                        int posx = i + dx[d];
                        int posy = j + dy[d];
                        if (0 <= posx && posx < N && 0 <= posy && posy < W) {
                            if ("#".equals(s[posx][posy]))
                                cnt++;
                        }
                    }
                    t[i][j] = String.valueOf(cnt);
                }
            }
        }
        for (int i=0; i<N; i++) {
            StringBuffer sb = new StringBuffer();
            for (int j = 0; j < W; j++) {
                sb.append(t[i][j]);
            }
            System.out.println(sb);
        }
    }
}


Measured memory_bytes: 22996
//encoding:utf-8
#include <iostream> //c++
#include<time.h> //時間にかんして
#include<stack> //スタックに関して　最新のデータから捨てる
#include<queue> //キューに関して　最古のデータから捨てる
#include<math.h>
#include<vector>
#include<algorithm> //sort とかにいる

#define ll long long
using namespace std;
int main(){
  int n;
  cin>>n;
  int A[2][n];
  int B[2][n];
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin>>A[i][j];
      B[i][j] = 0;
    }
  }
  B[0][0] = A[0][0];
  B[1][0] = A[1][0]+A[0][0];

  for(int i=0;i<2;i++){
    for(int j=1;j<n;j++){
      if(i==0){
        B[i][j] = B[i][j-1]+A[i][j];
      }
      else{
        B[i][j] = max(B[i-1][j],B[i][j-1])+A[i][j];
      }

    }
  }
  cout<<B[1][n-1]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long long n,a,b,c,d,e;cin >> n >> a >> b;
  c = n*a+(b-a);d = n*b-(b-a);e = d-c+1;
  if(e<0) e=0;
  cout << e << endl;
}
  

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	static int solve(int hPattern , int S[][] , int K){
		int H = Integer.bitCount(hPattern) + 1;
		int W = S[0].length;
		int A[][] = new int[H][W];
		List<Integer> hcuts = new ArrayList<Integer>();
		for(int i = 0 ; i < S.length ; ++i){
			if((hPattern & (1 << i)) != 0){
				hcuts.add(i);
			}
		}
		hcuts.add(S.length);
		for(int w = 0 ; w < W ; ++w){
			for(int i = 0 ; i < H ; ++i){
				int sum = 0;
				int l = i == 0 ? 0 : hcuts.get(i - 1) + 1;
				int r = Math.min(hcuts.get(i) , S.length - 1);
				for(int j = l ; j <= r ; ++j){
					sum += S[j][w];
				}
				A[i][w] = sum;
				if(sum > K){
					return -1;
				}
			}
		}
		int cum[] = new int[A.length];
		int cut = 0;
		for(int w = 0 ; w < W ; ++w){
			boolean needCut = false;
			for(int i = 0 ; i < H ; ++i){
				if(cum[i] + A[i][w] > K){
					needCut = true;
				}
			}
			if(needCut){
				cut++;
				Arrays.fill(cum, 0);
			}
			for(int i = 0 ; i < H ; ++i){
				cum[i] = cum[i] + A[i][w];
			}
		}
//		System.out.println(Integer.toBinaryString(hPattern)+" "+hcuts+" "+H);
//		System.out.println(Arrays.deepToString(A)+" "+cut +" "+(cut + H - 1));
		return cut;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int K = sc.nextInt();
		int S[][] = new int[H][W];
		for(int i = 0 ; i < H ; ++i){
			String s = sc.next();
			for(int j = 0 ; j < W ; ++j){
				S[i][j] = s.charAt(j) - '0';
			}
		}
		int ret = H * W;
		int P = 1 << (H - 1);
		for(int p = 0 ; p < P ; ++p){
			int r = solve(p , S , K);
			if(r >= 0){
				ret = Math.min(ret, r + Integer.bitCount(p));
			}
		}
		System.out.println(ret);
	}
}


Measured memory_bytes: 36232
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using graph=vector<vector<int>>;
using field=vector<string>;
using p =pair<int,int>;
const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    int k,s;
    cin>>k>>s;
    int ans=0;
    rep(x,k+1){
        rep(y,k+1){
            if(x+y<=s&&s-k<=x+y)++ans;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); if (n == 0) cout << endl; REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vi a(n);
    REP(i, n) cin >> a[i];
    SORT(a);
    auto c = lower_bound(a.begin(), a.end() - 1, a[n - 1] / 2);
    if (abs(a[n - 1] / 2 - *(c - 1)) <= abs(a[n - 1] / 2 + (n % 2) - *c)) {
        cout << a[n - 1] << " " << (*(c - 1)) << endl;
    } else {
        cout << a[n - 1] << " " << (*c) << endl;
    }
}


Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int a, b, c, k, s = 0;
  cin >> a >> b >> c >> k;
  rep(i, 0, k) {
    if(a > 0) {
      a--;
      s++;
    } else if(b > 0) {
      b--;
    } else if(c > 0) {
      c--;
      s--;
    }
  }
  cout << s;
}

Measured memory_bytes: 3636
n=int(input())
h=list(map(int,input().split()))
ans = 0
cnt = 0

for i in range(1,n):
    if h[i-1] >= h[i]:
        cnt += 1
        if i == n-1:
            ans = max(cnt, ans)
    else:
        ans = max(cnt, ans)
        cnt = 0
print(ans)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  string s;
  cin >> s;
  vector<int> ans(1e6);

  int i = 0;
  while (i < s.size()) {
    int current = i;
    int r_cnt = 0;
    int l_cnt = 0;
    while(s[i] == 'R') {
      r_cnt++;
      i++;
    }
    while(s[i] == 'L') {
      l_cnt++;
      i++;
    }

    int v = l_cnt + r_cnt;
    ans[current + r_cnt - 1] = v / 2;
    ans[current + r_cnt] = v / 2;
    if (v % 2 != 0) {
      if ((max(l_cnt, r_cnt) - 1) % 2 == 0) {
	if (l_cnt < r_cnt) {
	  ans[current + r_cnt - 1]++;
	} else {
	  ans[current + r_cnt]++;
	}
      } else {
	if (l_cnt < r_cnt) {
	  ans[current + r_cnt]++;
	} else {
	  ans[current + r_cnt - 1]++;
	}
      }
    }
  }

  for (int i = 0; i < s.size(); i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}


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

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var ws = new int[h[0]].Select(_ => read()).OrderBy(x => x[2]).ToArray();
		var d = new int[h[1]].Select(_ => int.Parse(Console.ReadLine())).ToList();
		var map = d.Select((x, i) => new { x, i }).ToDictionary(_ => _.x, _ => _.i);
		var c = new int[h[1]];

		foreach (var w in ws)
		{
			var si = d.BinarySearch(w[0] - w[2]);
			if (si < 0) si = ~si;
			var ti = d.BinarySearch(w[1] - w[2]);
			if (ti < 0) ti = ~ti;

			for (int i = si; i < ti; i++) c[map[d[i]]] = w[2];
			d.RemoveRange(si, ti - si);
		}
		Console.WriteLine(string.Join("\n", c.Select(x => x != 0 ? x : -1)));
	}
}


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

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

	int n = min(a, b);
	int m = max(a, b);

	if (n == 1 && m == 2) {
		cout << 3;
	} else if (n == 2 && m == 3) {
		cout << 1;
	} else if (n == 1 && m == 3) {
		cout << 2;
	}
	
	return 0;
}
	

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

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

int N, M;
int d[1111];
int in[1111];

int main(int argc, char *argv[])
{
  while(cin >> N >> M, N){
    rep(i, N) cin >> d[i];
    rep(i, M) cin >> in[i];

    int cur = 0;
    rep(i, M){
      cur += in[i] + d[cur + in[i]];
      if(cur >= N - 1){
        cout << i + 1 << endl;
        break;
      }      
    }
  }
  
  return 0;
}

Measured memory_bytes: 1168
from heapq import heapify, heappush, heappop
def main():
    n, m = map(int, input().split())
    a = [-int(i) for i in input().split()]
    heapify(a)
    for _ in range(m):
        heappush(a, -(-heappop(a) // 2))
    print(-sum(a))
    
if __name__ == "__main__":
  main()

Measured memory_bytes: 14188
#include <bits/stdc++.h>
     
    using namespace std;
     
    typedef long long ll;
    typedef pair<int,int> ii;
    typedef vector<int> vi;
    typedef long double ld;
     
    #define fi first
    #define se second
    #define pb push_back
    #define mp make_pair
     
    const int MOD = 1e9 + 7;
    const int N = 2001;
     
    int a[200001];
    int b[200001];
    int dp[8001][8001];
     
    int choose(int a, int b)
    {
    	if(a < b) return 0;
    	if(dp[a][b] != -1) return dp[a][b];
    	if(b == 0) return 1;
    	if(b == 1) return a;
    	dp[a][b] = (ll(choose(a - 1, b)) + ll(choose(a - 1, b - 1)))%MOD;
    	return dp[a][b];
    }
     
    ll modpow(ll a, ll b)
    {
    	ll r = 1;
    	while(b)
    	{
    		if(b&1) r = (r*a)%MOD;
    		a = (a*a)%MOD;
    		b>>=1;
    	}
    	return r;
    }
     
    int main()
    {
    	ios_base::sync_with_stdio(0); cin.tie(0);
    	int n;
    	cin >> n;
    	for(int i = 0; i < n; i++)
    	{
    		cin >> a[i] >> b[i];
    	}
    	for(int i = 0; i < n; i++)
    	{
    		dp[-a[i]+N][-b[i]+N]++;
    		//dp2[a[i]+N][b[i]+N]++;
    	}
    	
    	for(int i = 1; i <= 4010; i++)
    	{
    		for(int j = 1; j <= 4010; j++)
    		{
    			dp[i][j] = (ll(dp[i][j]) + ll(dp[i - 1][j]) + ll(dp[i][j - 1]))%MOD;
    		}
    	}
    	
    	ll ans = 0;
    	ll ans2 = 0;
    	
    	for(int i = 0; i < n; i++)
    	{
    		ans += dp[a[i]+N][b[i]+N];
    		ans %= MOD;
    	}
    	
    	memset(dp, -1, sizeof(dp));
    	
    	for(int i = 0; i < n; i++)
    	{
    		ans2 += choose(2*(a[i]+b[i]), 2*b[i]);
    		ans2 %= MOD;
    	}
    	
    	ans = (ans - ans2)%MOD;
    	if(ans < 0) ans += MOD;
    	ans = (ans*modpow(2, MOD - 2))%MOD;
    	if(ans < 0) ans += MOD;
    	cout << ans;
    	return 0;
    }

Measured memory_bytes: 252288
import java.math.BigInteger;
import java.util.*;
 
public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        int N = sn.nextInt();
        BigInteger result = BigInteger.ONE;
        long x = (long)Math.pow(10, 18);
        int flag = 0;
 
        long[] A = new long[N];
 
        for(int n=0; n<N; n++){
            A[n] = sn.nextLong();
            if (A[n] == 0) flag = 1;
        }
 
        if(flag == 1) System.out.println(0);
        else{
            for(int n=0; n<N; n++){
                result = result.multiply(BigInteger.valueOf(A[n]));
                if(result.compareTo(BigInteger.valueOf(x)) == 1){
                    System.out.println(-1);
                    flag = 2;
                    break;
                }
            }
            if(flag != 2)System.out.println(result);
        }
    }
}

Measured memory_bytes: 61780
#include<bits/stdc++.h>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
#define ODD 1
#define EVEN 0

signed main() {
    int n;
    cin >> n;
    vector<vi> table(n, vi(3));
    rep(i, n){
        rep(j, 3){
            cin >> table[i][j];
        }
    }

    int now_x = 0, now_y = 0, now_time = 0;

    bool can_travel = true;

    rep(i, n){
        int diff = abs(now_x - table[i][1]) + abs(now_y - table[i][2]);
        int diff_time = table[i][0] - now_time;
        now_x = table[i][1];
        now_y = table[i][2];
        now_time = table[i][0];
        if(diff > diff_time) can_travel = false;
    }

    now_x = 0, now_y = 0, now_time = 0;
    int cur = ODD, mukasi = EVEN;
    rep(i, n){
        if((table[i][0] - now_time)%2 == ODD && abs((now_x+now_y)-table[i][1]+table[i][2])%2 == EVEN) can_travel = false;
        if((table[i][0] - now_time)%2 == EVEN && abs((now_x+now_y)-table[i][1]+table[i][2])%2 == ODD) can_travel = false;
        now_x = table[i][1];
        now_y = table[i][2];
        now_time = table[i][0];
    }

    if(can_travel) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 8784
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (k,n) = get!(isize, usize);
    let a = get!([isize]);

    let mut mn = std::isize::MAX;
    for i in 0..n-1 {
        mn = min!(mn, k-(a[i+1]-a[i]));
    }
    mn = min!(mn, k-(a[0]+k-a[n-1]));
    println!("{}", mn);
}


Measured memory_bytes: 14588
row = list(map(int, input().split()))
min_pay = 5000 * 1e+5 * 2
if row[3] > row[4]:
    Z = row[3]
else:
    Z = row[4]
for z in range(2*Z+1):
    if z % 2 == 0:
        x = row[3] - z / 2
        y = row[4] - z / 2 
        if x < 0:
            x = 0
        if y < 0:
            y = 0
        pay = x*row[0] + y*row[1] + z*row[2]
        if pay < min_pay:
            min_pay = pay
            
print(int(min_pay))
            

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(double.Parse).ToArray();

            double sum = 0;
            for(var i = 0; i < N; i++)
            {
                sum += 1 / a[i];
            }

            Console.WriteLine(1 / sum);

            //Console.Out.Flush();

        }
    }

    //010100

    public class Calculation
    {

    }

    public class Graph
    {

    }
}




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

int main(){
	string S;
	cin >> S;
	int cnt = 0, f = 1;
	for(int i=0; i<S.size(); i++){
		if(f && S[i] == '1'){
			cnt++;
		}else{
			f = 0;
		}
	}
	f = 1;
	char ans;
	for(int i=0; i<S.size(); i++){
		if(f && S[i] != '1'){
			ans = S[i];
			f = 0;
		}
	}
	int K;
	cin >> K;
	if(cnt >= K) cout << 1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[200005];
int n;

LL func(LL b){
	LL res = 0;
	for(int i=1;i<=n;i++){
		res += abs(a[i] - (b+i));
	}
	return res;
}

int main(){
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%lld", &a[i]);
	LL lo = -1e9, hi = 1e9;
	LL ans = 1e18;
	for(int i=0;i<200;i++){
		LL mid1 = (lo*2+hi)/3;
		LL mid2 = (lo+2*hi)/3;


		LL res1 = func(mid1), res2 = func(mid2);
		if(res1 < res2) hi = mid2, ans = min(ans, res1);
		else lo = mid1, ans = min(ans, res2);

	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1792
import re

n=input()
min=10000000
N=len(n)
for i in range(N-1):
    if n[i]!=n[i+1]:
        if max(i+1,N-i-1) < min:
            min=max(i+1,N-i-1)
if min==10000000:
    min=N

print(min)


Measured memory_bytes: 3444
import fractions as f
n,m=map(int,input().split())
s=list(input())
t=list(input())
ans=0
N=n//f.gcd(n,m)
M=m//f.gcd(n,m)
for i in range(f.gcd(n,m)):
    if s[i*N]!=t[i*M]:
        ans=-1
        break
if ans!=-1:
    print(n*m//f.gcd(n,m))
else:
    print(-1)
#print(cnt)



Measured memory_bytes: 6580
/**
 *      ABC 112 D
 *      author  : kyomukyomupurin
 *      created : 2018-10-06 21:18:38
**/

#include <bits/stdc++.h>
#define int32 int_fast32_t
#define int64 int_fast64_t
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int32 N, M; cin >> N >> M;
    int32 pos = M / N;

    while (1){
        if (M % pos == 0){
            cout << pos << '\n'; return 0;
        }
        else {
            --pos;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())

for h in range(1, 3501):
  for n in range(1, 3501):
    if 4*n*h-N*n-N*h == 0:
      continue
    w = N*h*n/(4*n*h-N*n-N*h)
    if w > 0 and w.is_integer():
      ans = [n, h, int(w)]
print(*ans)

Measured memory_bytes: 41948
#include <cstdio>
#include <vector>
#include <algorithm>
using std::sort;
using std::vector;

int min(int a, int b){return (a<b)?a:b;}

const int MAXN = 500+10;
const int MAXEDGE = MAXN * MAXN;

struct edge{int u, v, c;}Edge[MAXEDGE];
bool comp(edge a, edge b){return a.c < b.c;}
vector<edge> graph[MAXN];
bool used[MAXEDGE];

int SET[MAXN];
int Find(int x){
    if(SET[x]==x) return x;
    else return SET[x] = Find(SET[x]);
}

int res=0, sum=0;
int dfs_no[MAXN];
int low[MAXN];
int dfs_time;

int Tarjan(int u,int fa, int Cost){
    low[u] = dfs_no[u] = ++dfs_time;
    for(int i=0 ; i<graph[u].size() ; i++){
        int to;
        if(graph[u][i].u == u) to = graph[u][i].v;
        if(graph[u][i].v == u) to = graph[u][i].u;
        if(to==fa || to==u) continue;
        if(dfs_no[to]) low[u] = min(low[u], low[to]);
        else{
            int lowto = Tarjan(to, u, Cost);
            if(lowto > dfs_no[u] && graph[u][i].c==Cost){
                res++;
                sum+=Cost;
            }
            low[u] = min(low[u], lowto);
        }
    }
    return low[u];
}

int main(){
    int N, M;
    scanf("%d %d", &N, &M);
    for(int i=1;i<=N;i++)
        SET[i] = i;
    for(int i=0;i<M;i++)
        scanf("%d %d %d", &Edge[i].u, &Edge[i].v, &Edge[i].c);
    sort(Edge, Edge+M, comp);
    for(int i=0 ; i<M ;){
        int cost=Edge[i].c;
        int r;
        for(r=i ; r<M && Edge[r].c==cost ; r++);
        for(int j=i ; j<r ; j++){
            int u = Edge[j].u;
            int v = Edge[j].v;
            int set1 = Find(u);
            int set2 = Find(v);
            if(set1 == set2) continue;
            graph[u].push_back(Edge[j]);
            graph[v].push_back(Edge[j]);
        }
        dfs_time=1;
        for(int j=1;j<=N;j++) low[j] = dfs_no[j] = 0;
        for(int j=1;j<=N;j++){
            if(dfs_no[j]==0) Tarjan(j, 0, cost);
        }
        for(int j=i ; j<r ; j++){
            int u = Edge[j].u;
            int v = Edge[j].v;
            int set1 = Find(u);
            int set2 = Find(v);
            if(set1 == set2) continue;
            graph[u].pop_back();
            graph[v].pop_back();
        }
        for(int j=i ; j<r ; j++){
            int u = Edge[j].u;
            int v = Edge[j].v;
            int set1 = Find(u);
            int set2 = Find(v);
            if(set1 != set2){
                graph[u].push_back(Edge[j]);
                graph[v].push_back(Edge[j]);
                SET[set1] = set2; 
            }           
        }
        i = r;
    }
    printf("%d %d\n", res, sum);
    return 0;
}

Measured memory_bytes: 3320
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	m := make(map[string]int)

	for _, v := range s {
		m[string(v)]++
	}
	for _, v := range m {
		if v != 2 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MAXN 200010
using namespace std;
int  n,m,k;
long long  a[MAXN],b[MAXN];

int main(){
	cin>>n>>m>>k;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]+=a[i-1];
	}
	for(int i=1;i<=m;i++){
		cin>>b[i];
		b[i]+=b[i-1];
	}
	for(int i=0;i<n+1;i++){
		long long ex=k-a[i];
		if(ex>=0){
			int j=upper_bound(b,b+m+1,ex)-b-1;
			ans=max(ans,i+j);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6644
#include <iostream>
using namespace std;
int main(){
	while(true){

	int n,m;
	cin >> n;
	if(n == 0) return 0;
	m = 0;
	n = 1000-n;

	if(n>=500){
		m = n/500;
		n = n%500;
	}
	if(n>=100){
		m = m+n/100;
		n = n%100;
	}
	if(n>=50){
		m = m+n/50;
		n = n%50;
	}
	if(n>=10){
		m = m+n/10;
		n = n%10;
	}
	if(n>=5){
		m = m+n/5;
		n = n%5;
	}
	if(n>=1){
		m = m+n/1;
	}

	cout << m << endl;

	}

}


Measured memory_bytes: 3040
//
//  main.cpp
//  B
//
//  Created by 黄宇凡 on 2017/4/9.
//  Copyright © 2017年 黄宇凡. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int n,k;

const int maxn = 25;

int a[maxn];
int c[maxn];

int main(int argc, const char * argv[]) {
    cin >> n >> k;
    long long ans = 1e18;
    for(int i = 0;i < n;i++) cin >> a[i];
    for(int i = 0;i < (1 << n);i++){
        int num = 0;
        for(int j = 0;j < n;j++){
            if(i & (1 << j)){
                num++;
                c[j] = 1;
            }else c[j] = 0;
        }
        if(num >= k){
            //cout << i << endl;
            long long tmp = 0;
            int pre = 0;
            for(int j = 0;j < n;j++){
                if(c[j] == 1){
                    if(a[j] > pre){
                        pre = a[j];
                    }else{
                        tmp += pre + 1 - a[j];
                        pre = pre + 1;
                    }
                }else{
                    pre = max(pre,a[j]);
                }
            }
            ans = min(ans,tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def bsearch(target, min_i, max_i, func):
    # func(index) <= target < func(index+1) となるindexを返す
    if func(max_i) < target:
        return max_i
    if target <= func(min_i):
        return None
    index = (max_i + min_i)//2
    while True:
        if max_i - min_i <= 1:
            return min_i
        if func(index) < target:
            index, min_i = (index + max_i)//2, index
            continue
        index, max_i = (index + min_i)//2, index


def f(N):
    def g(i):
#        print(i,I,J)
        if i < I or J < i:
            return i*(N-i+1)
        elif i == I:
            return 0
        elif I < J:
            return i*(N-i+2)
        else:
            return i*(N-i)
    I, J = A,N-B+1
    return max(g(N//2), g(N//2+1), g(N//2+2))

Q, = map(int, input().split())
for _ in range(Q):
    A, B = map(int, input().split())
    r = bsearch(A*B, 1, A*B, f)
    print(r-1)


Measured memory_bytes: 42480
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

x1, y1, x2, y2 = map(int, input().split())

x = x2 - x1
y = y2 - y1

print(x2 - y, y2 + x, x1 - y, y1 + x)


Measured memory_bytes: 9188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
int solve(){
  int n,m;
  cin >> n >> m;
  vector<int>a;
  rep(i,n)a.push_back(2);
  rep(i,m)a.push_back(3);
  ll ans = 0;
  rep(i,n + m)REP(j,i + 1,n + m){
    if(i == j)continue;
    if((a[i] + a[j]) % 2 == 0)ans++; 
  }
  cout << ans << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

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

using namespace std;
#define MAX 100010
#define INF 2000000000

int w[MAX], t[MAX];

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

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

	int max_wield = 0;
	for (int i = 0; i < n; i++)
	{
		max_wield = max(max_wield, w[i]);
	}

	sort(t, t + n);
	reverse(t, t + n);

	int sum_throw = 0;
	int count_throw = 0;
	int count_throw_only = -1;

	for (int i = 0; i < n; i++)
	{
		sum_throw += t[i];
		if (sum_throw >= h)
		{
			count_throw_only = i + 1;
			break;
		}
	}

	sum_throw = 0;
	for (int i = 0; i < n; i++)
	{
		if (t[i] > max_wield)
		{
			sum_throw += t[i];
			count_throw++;
		}
	}

	h = max(h - sum_throw, 0);

	int ans = 0;
	if (h % max_wield != 0)
	{
		ans = 1;
	}

	ans = ans + h / max_wield + count_throw;


	if (count_throw_only < ans && count_throw_only != -1)
	{
		ans = count_throw_only;
	}

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

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

using namespace std;

typedef long long ll;

const int maxn=2e6+10;

int prime[5000000];//保存素数
int vis[maxn];//初始化
int cnt;
 
void getprime(int n)
{
    cnt=0;
    memset(vis,0,sizeof(vis));
    for(int i=2;i<n;i++)
    {
        if(vis[i]==0)
            prime[cnt++]=i;
        for(int j=0;j<cnt&&i*prime[j]<n;j++)
        {
            vis[i*prime[j]]=1;
			// vis[i*prime[j]]=prime[j]; 
            if(i%prime[j]==0)
                break;
        }
    }
}

int num[maxn];
int a[maxn];

int main()
{
	getprime(maxn-5);
	int n;
	cin>>n;
	bool f1=true,f2=true;

	for( int i=1;i<=n;i++ ) cin>>a[i];
	
	for( int i=1;i<=n;i++ )
	{
		int p=a[i];
		for( int j=0;prime[j]<=p && j<cnt;j++ )
		{
			if( p%prime[j]==0 )
			{
				if( num[prime[j]] ) f1=false;
				num[prime[j]]=1;
				while( p%prime[j]==0 )
				{
					p/=prime[j];	
				}
				if( p==1 ) break;
			}
			if( !vis[p] )
			{
				if( num[p] ) f1=false;
				num[p]=1;
				break;
			}
		}
		
	}
	if( f1 )
	{
		puts("pairwise coprime");
		return 0;
	}
	
	int c=a[1];
	for( int i=2;i<=n;i++ ) c=__gcd(c,a[i]);
	
	if( c==1 ) puts("setwise coprime");
	else puts("not coprime");
}

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

int main(){
  int a, b, c, d, e;
  std::cin >> a >> b >> c >> d >> e;
  
  if(a==0){
    std::cout << "1";
  }else if(b==0){
    std::cout << "2";
  }else if(c==0){
    std::cout << "3";
  }else if(d==0){
    std::cout << "4";
  }else{
    std::cout << "5";
  }
  
  return 0;
}

Measured memory_bytes: 3572
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if ((i < B && j < A) || (i >= B && j >= A)) {
                cout << 1;
            } else {
                cout << 0;
            }
        }
        cout << endl;
    }
    return 0;
}

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

int main(){
	vector<vector<int>> c(3, vector<int>(3));
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			cin >> c.at(i).at(j);
		}
	}
	vector<int> a(3), b(3);
	bool finish=0;
	a.at(0)=0;
	for(int i=0; i<3; i++){
		b.at(i)=c.at(0).at(i);
		a.at(i)=c.at(i).at(0)-b.at(0);
	}
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			if(c.at(i).at(j)!=a.at(i)+b.at(j)){
				finish=1;
				break;
			}
		}
		if(finish){
			break;
		}
	}
	if(finish){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
}



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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

int main(){
    int sx, sy, tx, ty;
    scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
    rep(i, 0, tx-sx){
        printf("R");
    }
    rep(i, 0, ty-sy){
        printf("U");
    }
    rep(i, 0, tx-sx){
        printf("L");
    }
    rep(i, 0, ty-sy){
        printf("D");
    }
    printf("D");
    rep(i, 0, tx-sx+1){
        printf("R");
    }
    rep(i, 0, ty-sy+1){
        printf("U");
    }
    printf("LU");
    rep(i, 0, tx-sx+1){
        printf("L");
    }
    rep(i, 0, ty-sy+1){
        printf("D");
    }
    printf("R");

    return 0;
}

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

using namespace std;

string ans;
int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    if(s1[s1.size()-1] == s2[0] && s2[s2.size()-1] == s3[0]){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i) {
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;

    if( l <= H && A[l] > A[i] ) largest = l;
    else largest = i;
    if ( r <= H && A[r] > A[largest] ) largest = r;

    if ( largest != i ){
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract() {
    int maxv;
    if ( H < 1 ) return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key) {
    if ( key < A[i] ) return;
    A[i] = key;
    while ( i > 1 && A[i / 2] < A[i] ) {
        swap(A[i], A[i / 2]);
        i = i / 2; 
    }
}

void insert(int key) {
    H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main() {
    int key;
    char com[10];

    while ( 1 ) {
        scanf("%s", com);
        if ( com[0] == 'e' && com[1] == 'n' ) break;
        if ( com[0] == 'i' ) {
            scanf("%d", &key);
            insert(key);
        } else {
            printf("%d\n", extract());
        }
    }

    return 0;
}


Measured memory_bytes: 6620