akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

int main()
{
  int N;
  std::cin>>N;
  std::vector<std::vector<std::vector<int>>> people(N);
  for(int i=0;i!=N;i++)
  {
    int A;
    std::cin>>A;
    people[i].resize(A);
    for(int j=0;j!=A;j++)
    {
      int x;
      int y;
      std::cin>>x>>y;
      x--;
      people[i][j].assign({x,y});
    }
  }
  
  int maxHonests=0;
  for(int i=1;i!=(1<<N);i++)
  {
    int curHonests=0;
    for(int j=0;j!=N;j++)
    {
      if((i&(1<<j))==0)
        continue;
      
      curHonests++;
      for(int k=0;k!=people[j].size();k++)
      {
        int x=people[j][k][0];
        int y=people[j][k][1];
        if((((i&(1<<x)))==0)!=(y==0))
        {
          curHonests=0;
          j=N-1;
          break;
        }
      }
    }
    if(curHonests>maxHonests)
    {
      maxHonests=curHonests;
    }
  }
  
  std::cout<<maxHonests<<std::endl;
  
  return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 a,b;
    cin >> a >> b;
    cout << (b - 1 + a - 1 - 1) / (a - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

cnt = 0

for num in range(0, n-2):
  if A[num+1] > A[num] and A[num+1] < A[num+2]:
    cnt += 1
  elif A[num+1] < A[num] and A[num+1] > A[num+2]:
    cnt +=1

print(cnt)

Measured memory_bytes: 3060
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let [|n;a;b|] = reada int
    let f n =
        let rec loop n acc =
            if n <= 0 then acc
            else loop (n / 10) (acc + n % 10)
        loop n 0

    let g x =
        let y = f x
        a <= y && y <= b

    [0..n]
    |> Seq.filter g
    |> Seq.sum
    |> printfn "%d"
    0


Measured memory_bytes: 14288
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
vector<int> ki[110000];
const int mod = 1000000007;
//0:black
//1:white
int dp[110000][2];
void dfs(int now,int last = -1){
    dp[now][0] = dp[now][1] = 1;
    for(int next:ki[now]){
        if(next == last)continue;
        dfs(next,now);
        dp[now][0] = (dp[now][0]*dp[next][1])%mod;
        dp[now][1] = (dp[now][1]*(dp[next][0]+dp[next][1])%mod)%mod;
        
    }
}
signed main(){
    int n;cin >> n;
    rep(i,n-1){
        int a,b;cin >> a >> b;
        a--;b--;
        ki[a].push_back(b);
        ki[b].push_back(a);

    }
    dfs(0);
    cout << (dp[0][0] + dp[0][1] )%mod<< endl;
    return 0;
}

Measured memory_bytes: 17680
#include <stdio.h> 
#include <iostream>
#include <algorithm>
using namespace std;
long long int gcd(long long int x,long long int y)
{ 
    long long int r;
    while(y!=0)
    {
    r=y;
    y=x%y;
    x=r;
    }
    return (x);
}

int main()
{
    int n;
	cin>>n;
	long long int s[100];
	long long int num=1;
	for (int i=0;i<n;i++)
	{
	    scanf ("%lld",&s[i]);
	    long long int m=gcd(num,s[i]);
	    num=num/m*s[i];
	}
	printf("%lld",num);
	return 0;
}


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


int main() {
    int N; cin >> N;
    int num = 1;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        if(a == num) num++;
        else ans++;
    }
    if(ans == N) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

    int n, k;
    cin >> n >> k;

    vector<ll> v1, v2;

    for (int i = 0; i < n; i++) {
    	ll x;
    	cin >> x;

    	if (x >= 0)
    		v1.push_back(x);
    	else
    		v2.push_back(-x);
    }

    reverse(all(v2));
    v1.insert(v1.begin(), 0);
    v2.insert(v2.begin(), 0);


    ll ans = 1e18;

    for (int i = 0; i < v1.size(); i++) {
    	if (i > k)
    		break;
    	if (i + int(v2.size()) - 1 >= k) {
    		ans = min(ans, v1[i] * 2 + v2[k - i]);
    		ans = min(ans, v1[i] + v2[k - i] * 2);
    	}
    }

    cout << ans << "\n";

    return 0;   
}   

Measured memory_bytes: 1656
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		String line = readLine();
		String[] strArray = line.split(" ");
		int[] array = new int[strArray.length];
		for(int i = 0; i < array.length; i++ ) {
			array[i] = Integer.parseInt(strArray[i]);
		}
		int distanceA = Math.abs(array[0] - array[1]);
		int distanceB = Math.abs(array[0] - array[2]);
		if(distanceA > distanceB) {
			System.out.println("B");
		} else {
			System.out.println("A");
		}
	}


	private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		return br.readLine();
	}
}

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

typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

string S, T;
int K, M;
ll res;

bool comp() {
	for (int i = 0; i < M; i++) {
		if (S[i] > T[i])return true;
		if (S[i] < T[i])return false;
	}
	return true;
}

int main() {
	cin >> S >> K;
	M = S.size();
	for (int i = 0; i < M; i++) {
		T.push_back('0');
	}
	if (K == 1) {
		for (int i = 0; i < M; i++) {
			for (char ci= '1'; ci <= '9'; ci++) {
				T[i] = ci;
				res += comp();
				T[i] = '0';
			}
		}
	}
	else if (K == 2) {
		for (int i = 0; i < M; i++) {
			for (char ci = '1'; ci <= '9'; ci++) {
				T[i] = ci;
				for (int j = i + 1; j < M; j++) {
					for (char cj = '1'; cj <= '9'; cj++) {
						T[j] = cj;
						res += comp();
						T[j] = '0';
					}
				}
				T[i] = '0';
			}
		}
	}
	else if (K == 3) {
		for (int i = 0; i < M; i++) {
			for (char ci = '1'; ci <= '9'; ci++) {
				T[i] = ci;
				for (int j = i + 1; j < M; j++) {
					for (char cj = '1'; cj <= '9'; cj++) {
						T[j] = cj;
						for (int k = j + 1; k < M; k++) {
							for (char ck = '1'; ck <= '9'; ck++) {
								T[k] = ck;
								res += comp();
								T[k] = '0';
							}
						}
						T[j] = '0';
					}
				}
				T[i] = '0';
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	string S;
	cin >> S;
	int A;
	for(int i=0; i<3; i++){
	if(S[i]=='o'){
	A++;
	}
	}
	cout << 700 + 100*A << endl;
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define mod 1000000007
using namespace std;
int n,k,sum,vis[100005];
vector<int>v[100005];
void dfs(int x){
	vis[x]=1;
	ll y;
	if(x==1)y=k-1;
	else y=k-2;
	for(int i=0;i<v[x].size();i++){
		int u=v[x][i];
		if(vis[u])continue;
		if(y==0)sum=0;
		else sum=(sum*y)%mod;
		y--;
		dfs(u);
	}
}
int main(){
	cin>>n>>k;sum=k;
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1);
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 9600
N = int(input())
ans = 1
if N ==1:
    print(1)
elif 2<=N<=3:
    print(2)
elif 4<=N<=7:
    print(4)
elif 8<=N<=15:
    print(8)
elif 16<=N<=31:
    print(16)
elif 32<=N<=63:
    print(32)
elif 64<=N<=100:
    print(64)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int main(){
    int n;
    int w[100];
    scanf(" %d",&n);
    for(int i=0;i<n;i++){
        scanf(" %d",&w[i]);
    }
    int ans = 65536;
    for(int i=1;i<n;i++){
        int l = 0; int r = 0;
        for(int j=0;j<i;j++){l += w[j];}
        for(int j=i;j<n;j++){r += w[j];}
        ans = ans > abs(l-r) ? abs(l-r):ans;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
  bool E[100001]={0};
  vector<int> P;
  for(int i=2;(long long)i*i*i<=10000000000ll;i++){
    if(!E[i]){
      for(int j=2*i;(long long)j*j*j<=10000000000ll;j+=i){
	E[j]=1;
      }
      P.push_back(i);
    }
  }
  int NP=P.size();
  int n;
  scanf("%d",&n);
  static long long S[100000];
  for(int i=0;i<n;i++){
    scanf("%lld",S+i);
  }
  static long long s[100000];
  for(int i=0;i<n;i++){
    s[i]=1ll;
    for(int j=0;j<NP&&(long long)P[j]*P[j]*P[j]<=S[i];j++){
      int c=0;
      while(S[i]%P[j]==0){
	S[i]/=P[j];
	c++;
      }
      if(c%3==1){
	s[i]*=P[j];
      }
      else if(c%3==2){
	s[i]*=P[j]*P[j];
      }
    }
    s[i]*=S[i];
  }
  sort(s,s+n);
  vector<pair<long long,int> > V;
  for(int i=0;i<n;i++){
    if(i==0||s[i-1]<s[i]){
      V.push_back(make_pair(s[i],1));
    }
    else{
      V[V.size()-1].second++;
    }
  }
  int a=0;
  for(int i=0;i<V.size();i++){
    long long A=V[i].first,B=1ll;
    if(A==1){
      a++;
      continue;
    }
    for(int j=0;j<NP&&(long long)P[j]*P[j]*P[j]<=A;j++){
      int c=0;
      while(A%P[j]==0){
	A/=P[j];
	c++;
      }
      if(c%3==1){
	if(0<=B&&B<=10000000000ll){
	  B*=P[j]*P[j];
	}
	else{
	  B=-1;
	}
      }
      else if(c%3==2){
	if(0<=B&&B<=10000000000ll){
	  B*=P[j];
	}
	else{
	  B=-1;
	}
      }
    }
    long long t=(long long)(sqrt((double)A)+0.5);
    if(t*t==A){
      if(0<=B&&B<=10000000000ll){
	B*=t;
      }
      else{
	B=-1;
      }
    }
    else{
      if(0<=B&&A<=1000000ll){
	B*=A*A;
      }
      else{
	B=-1;
      }
    }
    //printf("%lld %lld %lld\n",V[i].first,V[i].second,B);
    int j=lower_bound(V.begin(),V.end(),make_pair(B,0))-V.begin();
    if(j==V.size()||V[j].first>B){
      a+=V[i].second;
    }
    else if(V[i].first<V[j].first){
      a+=max(V[i].second,V[j].second);
    }
  }
  printf("%d\n",a);
  return 0;
}


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

int main() {
  int m = 0;
  int f = 0;
  int r = 0;

  while (1) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    }
    
    if (m == -1 || f == -1) {
      cout << "F" << endl;
    } else if ((m + f) >= 80) {
      cout << "A" << endl; 
    } else if ((m + f) >= 65 && (m+f) < 80) {
      cout << "B" << endl;
    } else if ((m + f) >= 50 && (m+f) < 65) {
      cout << "C" << endl;
    } else if ((m + f) >= 30 && (m+f) < 50) {
      if (r >= 50) {
        cout << "C" << endl;
      } else {
        cout << "D" << endl;
      }
    } else if ((m + f) < 30) {
        cout << "F" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1152
def resolve():
    import copy
    D = int(input())
    cost = list(map(int, input().split()))
    sat = [list((map(int, input().split()))) for _ in range(D)]
    last = [0]*26
    
    for i in range(D):
        maxcost = 0
        ans = 0
        
        for j in range(26):
            nowlast = copy.deepcopy(last)
            nowlast[j] = i+1
            plussat = sat[i][j]
            minussat = 0
            for k in range(26):
                minussat += (i + 1 - nowlast[k]) * (cost[k])
            cum = plussat-minussat
            
            if maxcost < cum:
                ans = j
                maxcost = cum

        print(ans+1)
resolve()

Measured memory_bytes: 71472
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int main(void)
{
    int N, K;
    char S;
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        cin >> S;
        if (i == K - 1)
        {
            cout << (char)(S + ('a' - 'A'));
        }
        else
        {
            cout << S;
        }
    }

    // Your code here!
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>

constexpr int MAX = 1000;

int dp[MAX][MAX + 1];
int W, n;
int v[MAX], w[MAX];

int main() {
	int cnt = 0;
	while (1) {
		std::cin >> W;
		if (W == 0)
			break;
		++cnt;
		std::cin >> n;
		char ch;
		for (int i = 0; i < n; ++i)
			std::cin >> v[i] >> ch >> w[i];
		std::memset(dp, 0, sizeof(dp));
		dp[0][w[0]] = v[0];
		for (int i = 1; i < n; ++i) {
			for (int j = 0; j <= W; ++j) {
				dp[i][j] = dp[i - 1][j];
				if (j >= w[i])
					dp[i][j] = std::max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
			}
		}
		int ans = 0, maxv;
		for (int i = W; i >= 0; --i) {
			if (ans <= dp[n - 1][i]) {
				ans = dp[n - 1][i];
				maxv = i;
			}
		}
		std::cout << "Case " << cnt << ':' << std::endl
			<< ans << std::endl << maxv << std::endl;
	}
	return 0;
}

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

int main(){
	int size;
	cin >> size;
	vector<int> heap(size*2);
	for(int i = 1; i <= size; i++){
		cin >> heap[i];
	}
	for(int i = 1; i <= size; i++){
		cout << "node " << i << ": key = " << heap[i] << ", ";
		if( i != 1 ) cout << "parent key = " << heap[i/2] << ", ";
		if( i*2 <= size ) cout << "left key = " << heap[i*2] << ", ";
		if( i*2+1 <= size ) cout << "right key = " << heap[i*2+1] << ", ";
		cout << endl;
	}
}

Measured memory_bytes: 1196
A[9999],B[9999];z(int*a,int*b){return*b-*a;}
main(n,i,j){for(;scanf("%d",&n),n;puts(i>n?"No":"Yes")){
for(i=0;i<n;i++)scanf("%d",A+i);
for(i=0;i<n;i++)scanf("%d",B+i);
for(i=qsort(A,n,4,z);i<n;A[i++]?i=n+1:1)for(j=0;j<n;j++)if(B[j])A[i]--,B[j]--;
}exit(0);}

Measured memory_bytes: 732
#include<stdio.h>
int main(void){
	int a[10000];
	int i=0;
	int j;
	
	while(1){
		scanf("%d",&a[i]);
		if(a[i]==0)break;
		i++;
	}
	
	for(j=0;j<i;j++){
		printf("Case %d: %d\n",j+1,a[j]);
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
#include <string>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    int n;
    int value_100;
    int value_10;
    int value_1;
    int ans;
    cin >> n;
    for(int i=n; i<=999; i++){
        value_1=i%10;
        value_10=(i/10)%10;
        value_100=(i/100);
        if(value_1==value_10 && value_10==value_100){
            ans=i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long


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

  ll a,p; cin >> a >> p;
  cout << (3*a+p)/2 << endl;

  return 0;
}

Measured memory_bytes: 764
from sys import exit, stdin
A, B, C = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
if A == B == C:
    if A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        print(-1)
        exit()
    else:
        print(0)
        exit()
else:
    while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        A, B, C = (A+B)//2, (B+C)//2, (C+A)//2
        ans += 1
print(ans)

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

int main()
{
    std::vector<int> a(3);
    for (int i = 0; i < 3; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end());

    int ans = a[0] + a[1];
    std::cout << ans << std::endl;
}


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

using namespace std;

int main()
{
    int n,l,ara[250],sum=0,temp;
    cin>>n>>l;

    for(int i=1;i<=n;i++){
        ara[i-1]=l+i-1;
        sum+=ara[i-1];
        if(l+i-1 < 0) ara[i-1]*=(-1);
    }
    int max=INT_MIN;

    if(sum<0) {
         temp=(-1)*sum;
    }else {
         temp=sum;
    }
    for(int i=0;i<n;i++){
        if(temp-ara[i] > max){
            max=temp-ara[i];
        }
    }
    if(sum<0) {
        max=-max;
        cout << max<<endl;
    }else {
        cout << max <<endl;

    }
    return 0;
}


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

using namespace std;

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

    int res = 0;

    int A[n];

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

    while(true)
    {
        bool odd = false;
        for(int i =0;i<n;++i)
        {
            if(A[i] % 2 != 0) odd = true;
        }

        if(odd)
        {
            break;
        }

        for(int i=0;i<n;++i)
        {
            A[i] /= 2;
        }

        ++res;
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;

#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
#define ll long long

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

	int n;
	cin >> n;
	vector<int> p(n);
	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		cin >> p[i];
		v[i] = p[i];
	}
	sort(all(v));
	int cnt = 0;
	for(int i = 0; i < v.size(); i++) {
		if(p[i] != v[i]) {
			cnt++;
		}
	}
	if(cnt == 2 || cnt == 0) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

n,m,q = map(int,input().split())
abcd = [[int(i) for i in input().split()] for j in range(q)]

s = [1] * (n)

#global ans
ans = 0

def dfs(k, c,old):
    global ans
    #awr = 0
    #ans = 0
    #print(s,k)
    if k == n:
        tmp = 0
        for i in range(q):
            if s[abcd[i][1]-1] - s[abcd[i][0]-1] == abcd[i][2]:
                tmp += abcd[i][3]
        ans = max(ans,tmp)
        #ans.append(tmp)
        return# ans
    for i in range(old,c+1):
        #print(old,c+1)
        s[k] = i
        dfs(k+1, m,i)
        #print(k+1,c)
    #s[k] = chr(c+ord('a'))
    #dfs(k+1, c+1)
    #return ans

#print(max(dfs(0, m,1,ans)))
dfs(0, m,1)
print(ans)

Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    if(n==1) cout<<"Hello World"<<endl;
    else{
        int a,b; cin >> a >>b;
        cout<<a+b<<endl;

    }
}

Measured memory_bytes: 3600
import java.io.*;
 
class Main
{
  public static void main(String args[])
  {
    int num;
    String buf;
    try {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      buf = br.readLine();
      num = Integer.parseInt(buf);
      System.out.println(num * num * num);
    } catch(Exception e) {
      System.out.println(e);
   }
  }
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    ll n, k;
    cin >> n >> k;

    cout << min(n % k, abs(n % k - k));

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
constexpr int MOD = 1e9+7, MX = 200005;
int n, v, u, s[MX];
vector<int> G[MX];
ll ans[MX], ac = 1;

ll rev(ll a){
	ll b = MOD, x = 1, y = 0, u = 0, v = 1;
	while(b){
		ll t = a / b;
		swap(a -= t * b, b);
		swap(x -= t * u, u);
		swap(y -= t * v, v);
	}
	x %= MOD;
	return x < 0 ? x+MOD : x;
}
ll dfs(int u, int p){
	ll v = s[u] = 1;
	for(int nx: G[u]) if(nx != p){
		(v *= dfs(nx, u)) %= MOD;
		s[u] += s[nx];
	}
	(v *= rev(s[u])) %= MOD;
	return v;
}
void dfs2(int u, int p){
	if(u != p) ans[u] = ans[p] * s[u] % MOD * rev(n-s[u]) % MOD;
	for(int nx: G[u]) if(nx != p) dfs2(nx, u);
}
int main(){
	scanf("%d", &n);
	rep(i,n) (ac *= i+1) %= MOD;
	rep(i,n-1){
		scanf("%d%d", &v, &u);
		v--; u--;
		G[v].push_back(u);
		G[u].push_back(v);
	}
	ans[0] = dfs(0,0) * ac % MOD;
	dfs2(0,0);
	rep(i,n) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 16244
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int test[1];
int main() {
	long long n, a, b, k, ans = 0; cin >> n >> a >> b;
	for (int h = 0; h < n; h++) {
		cin >> k;
		if (h != 0) {
			if ((k - test[0]) * a >= b) { ans += b; }
			else { ans += (k - test[0]) * a; }
		}
		test[0] = k;
	}
	cout << ans << endl;
	cin >> n;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  int a[m];
  int i;
  int front = 0, back = 0;
  for(i = 0; i < m; i++){
    cin >> a[i];
    if(a[i] < x) front++;
    else if(x < a[i]) back++;
  }
  if(front < back) cout << front << endl;
  else cout << back << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
int a[3],i,j,key;

scanf("%d %d %d",&a[0],&a[1],&a[2]);

for(i = 1;i < 3;i++){
key = a[i];
j = i - 1;
while(j >= 0 && a[j] > key){
a[j + 1] = a[j];
j--;
}
a[j+1] = key;
}

printf("%d %d %d\n",a[0],a[1],a[2]);

return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi l(2*n);
    rep(i, 2*n) cin >> l[i];
    sort(all(l));
    ll sum = 0;
    for(ll i=0; i<2*n; i+=2) sum += l[i];
    cout << sum << endl;
}

Measured memory_bytes: 3660
#include<iostream>

int main() {

	int A, B;
	std::cin >> A >> B;
    
	int res = 0;

	for (int i = A; i <= B; i++) {

		int s = i % 10;
		int t = i / 10000;

		int u = i / 10 % 10;
		int v = i / 1000 % 10;

		if (s == t && u == v)res++;

	}

	std::cout << res << std::endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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()
{
  ll h, w;
  cin >> h >> w;
  if(h==1 || w==1){
    cout << 1 << endl;
    return 0;
  };
  cout << (h * w + 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
from fractions import gcd


def primes(N):
    p = [False, False] + [True] * (N - 1)
    for i in range(2, int(N ** 0.5) + 1):
        if p[i]:
            for j in range(i * 2, N + 1, i):
                p[j] = False
    return [i for i in range(N + 1) if p[i]]


def prime_factors(N):
    ret = []
    for p in primes(int(N ** 0.5) + 1):
        while N % p == 0:
            ret.append(p)
            N //= p
    if N > 1:
        ret.append(N)
    return ret


A, B = map(int, input().split())
g = gcd(A, B)
print(len(set(prime_factors(g))) + 1)


Measured memory_bytes: 20600
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    bitset<2000*2000> bit;
    bit[0] = true;
    rep(i,0,N){
        bit |= bit << V[i];
    }
    int cnt = 0, sum = bit.count();
    rep(i,0,2000*2000){
        cnt += bit[i];
        if(cnt == sum / 2 + 1){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
//
// Created by 吉川純平 on 2019-12-01.
//

#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
//using ull = unsigned long long;
#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll n;
  cin >> n;
  vector<ll> s(n);
  rep(i,n){
    cin >> s[i];
  }
  ll q;
  cin >> q;
  vector<ll> t(q);
  rep(i,q){
    cin >> t[i];
  }
  sort(all(s));
  ll ans = 0;
  rep(i,q){
    ll first = 0;
    ll last = n;
    bool can = false;
    while(first != last){
      tmp1 = (first + last) / 2;
      if(s[tmp1] == t[i]){
        can = true;
        break;
      }else if(s[tmp1] > t[i]){
        last = tmp1;
      }else{
        first = tmp1+1;
      }
    }
    if(can){
      ans++;
    }
  }
  cout << ans << endl;
}



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

int main()
{

    int a,b,c;

    scanf("%d%d",&a,&b);

    if(b%2==0 && b>=2 && b<=1000 && a>=0 && a<=100){
        if(a>=13) printf("%d\n",b);
        if(a>=6 && a<=12) printf("%d\n",b/2);
        if(a<=5) printf("0");
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    ll k, a, b;
    cin >> k >> a >> b;

    ll ans = 0LL;
    if (1 + k <= a || b-a < 2) {
        ans = 1 + k;
    } else {
        k -= a - 1;
        ans = a + (k / 2) * (b - a);

        if (k % 2 == 1) {
            ans++;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> accumA(N);
    vector<int> accumB(N);
    for(int i = 0;i < N;i++){
        cin >> accumA[i];
        if(i)accumA[i] += accumA[i-1];
    }
    for(int i = 0;i < N;i++){
        cin >> accumB[i];
        if(i)accumB[i] += accumB[i-1];
    }
    int maxi = 0;
    for(int i = 0;i < N;i++){
        int num = accumA[i] + accumB[N-1];
        if(i)num -= accumB[i-1];
        maxi = max(maxi, num);
    }
    cout << maxi << endl;
}

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

int main() {
  
  int a,x;
  int fx = 0;
  cin >> x;
  int tmp = x;
  
  while(tmp){
    fx += tmp%10;
    tmp /= 10;
  }
  
  if(x%fx == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int H,W,N;cin >> H >> W >> N;
    if(H > W) swap(H,W);
    cout << (W + N - 1)/W << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vll a(N),b(N);
    rep(i,N) cin>>a[i]>>b[i];
    sort(all(a)); sort(all(b));
    if (N%2==0){
        cout<<(b[(N-1)/2]+b[N/2])-(a[(N-1)/2]+a[N/2])+1<<endl;
    }else{
        int mid = N/2;
        cout<<b[mid]-a[mid]+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 6368
#include<stdio.h>
#define N 100000
int main(){
    int n,i,j,x[N],num=0,min=1000000,top=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
        if(x[i]>top) top=x[i];
    }
    for(i=0;i<=top;i++){
            num=0;
        for(j=0;j<n;j++){
            num+=(x[j]-i)*(x[j]-i);
        }
        if(min>num) min=num;
    }
    printf("%d\n",min);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;

	int res = 2 * min(B, C);
	B -= res/2;
	C -= res/2;
	if (C == 0) {
		res += B;
	}
	else {
		int t = min(A, C);
		res += t;
		B -= t;
		C -= t;
		if (C > 0)res++;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	string s;cin>>s;
	rep(i,s.size()){
		for(int j=i;j<s.size();j++){
			string t;
			for(int k=0;k<i;k++)t+=s[k];
			for(int k=j;k<s.size();k++)t+=s[k];
			if(t=="keyence"){
				puts("YES");return 0;
			}
		}
	}
	puts("NO");
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

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

  vector<int> L(N);
  REP(i, N) cin >> L[i];

  sort(all(L));

  ll ans = 0;
  for(int i = 0; i < N; i++){
      for(int j = i + 1; j < N; j++){
          auto ite = lower_bound(all(L), L[i] + L[j]) - L.begin();
          ans += (ite - j) - 1;
      }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        static int N=sc.nextInt();
        static long[]a=new long[N];
        
        
        public static void main(String[]args){
                int sum=0;

                for(int i=0;i<N;i++){
                        a[i]=sc.nextLong();}
                        long x=0;
                for(int i=0;i<N;i++){
                        x=a[i];
                        for(;;){
                                if(x%2==0){
                                        sum++;
                                        x=x/2;
                                }else{
                                        break;
                                }
                        }

                }
                System.out.println(sum);
                
                

        }
        
        
        

		
	
}


Measured memory_bytes: 34252
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
ll check(ll n)
{
    ll s=0;
    while(n>0)
    {
        s+=(n%10);
        n/=10;
    }
    return s;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll i,j,n,s=0,a,b;
    cin>>n>>a>>b;
    for(i=1;i<=n;i++)
    {
        j=check(i);
        if(j>=a&&j<=b)
        s+=i;
    }
    cout<<s<<"\n";
    return 0;
}

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


int main(){

int N,D;
// scanf("%d %d",&N,&D);
(void)scanf("%d %d",&N,&D);

int X[N],Y[N];
for(int i=0;i<N;i++){
	(void)scanf("%d %d",&X[i],&Y[i]);	
}

// for(int i=0;i<N;i++){
// 	printf("%d %d\n",X[i],Y[i]);	
// }
// return 0;

int num=0;
for(int i=0;i<N;i++){
	double a=pow(X[i],2);
	double b=pow(Y[i],2);
  //printf("%d %lf\n\n",X[i],pow(X[i],2));
	//printf("a%lf b%lf\n",a,b);
	double l=sqrt(a+b);
	//printf("%lf %lf\n",a,l);
	if(l<D || l==D)num++;
}
printf("%d\n",num);


return 0;

}


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

typedef long long ll;
const int maxn=1e5+10;
ll n,c,x[maxn],v[maxn],a[maxn],b[maxn],ans;

int main(){
	cin>>n>>c;
	for(int i=1;i<=n;++i)
		cin>>x[i]>>v[i];
	for(int i=1;i<=n;++i)
		a[i]=a[i-1]+v[i];
	for(int i=n;i;--i)
		b[i]=b[i+1]+v[i];
	for(int i=1;i<=n;++i){
		ans=max(ans,a[i]-x[i]);
		ans=max(ans,b[i]-(c-x[i]));
	}
	ll tmp1=-1e18,tmp2=-1e18;
	for(int i=n-1;i;--i){
		tmp1=max(tmp1,b[i+1]-(c-x[i+1]));
		tmp2=max(tmp2,b[i+1]-2*(c-x[i+1]));
		ans=max(ans,a[i]+tmp1-2*x[i]);
		ans=max(ans,a[i]+tmp2-x[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a, reverse=True)
    ans = sum(a[:(n + 1) // 2]) * 2 - a[0]
    ans -= a[(n + 1) // 2 - 1] if n % 2 else 0
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 32924
N = int(input())						# 5

Y="Yes"
ans="No"

if N<4:
	print(ans)
	exit(0)

if (N % 4 ==0)or(N % 7 ==0):
	print(Y)
	exit(0)

if ((N % 7) % 4)==0:
	print(Y)
	exit(0)

if ((N % 4) % 7)==0:
	print(Y)
	exit(0)


for i in range(16):
	a = N - (7*i)
	if a<4: continue
	
	if a%4==0:
		ans=Y
		break


print(ans)


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

int main(void){
    ll x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    cout << x2 - (y2 - y1) << " " << y2 + (x2 - x1) << " " << x1 - (y2 - y1) << " " << y1 + (x2 - x1) << endl;

    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i,j,W,H;
    while(1){
        scanf("%d %d",&W,&H);
        if(W == 0 && H == 0){
                    break;
                }
        for(i = 0;i < W;i++){
            for(j = 0;j < H;j++){
                if(i == 0 || i == W-1 || j == 0 || j == H-1){
                    printf("#");
                }else{
                    printf(".");
                }
            }printf("\n");
        }
        printf("\n");
    }
     
    return 0;
}
	
	

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

int main()
{
  int k;
  string s;
  cin >> k >> s;

  if(s.size() > k){
    for(int i = 0; i < k; i++){
      cout << s[i];
    }

    cout << "..." << endl;
  }
  else{
    cout << s << endl;
  }

  return 0; 
}


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

using namespace std;

const int MAXN = 1e5 + 10;
vector<int> adj[MAXN];
bool visited[MAXN];
map<pair<int, int>, bool> edg;

int pos[MAXN];
vector<int> st;

int dp[MAXN];

void dfs(int v) {
    visited[v] = 1;
    for (auto u : adj[v])
        if (!visited[u])
            dfs(u);
    st.push_back(v);
    pos[v] = st.size();
}

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

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;

        a--, b--;

        adj[a].push_back(b);
        edg[make_pair(a, b)] = 1;
    }

    for (int i = n-1; i >= 0; i--)
        if (!visited[i])
            dfs(i);

    reverse(st.begin(), st.end());

    for (int i = n-1; i >= 0; i--)
        for (auto v : adj[st[i]])
            dp[st[i]] = max(dp[st[i]], dp[v] + 1);

    int ans = 0;
    for (int i = 0; i < n; i++)
        ans = max(ans, dp[i]);

    cout << ans;
    return 0;
}

Measured memory_bytes: 14844
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int A[2000000];
int B[2000000];
int C[10001];

void CountingSort(int n,int k)
{
	for (int i = 0; i < 10001; i++)
	{
		C[i] = 0;
	}

	for (int i = 0; i < n; i++)
	{
		C[A[i]]++;
	}

	for (int i = 1; i < k; i++)
	{
		C[i] += C[i - 1];
	}

	for (int i = 0; i < n; i++)
	{
		B[C[A[i]] - 1] = A[i];
		C[A[i]]--;
	}
}

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

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A[i]);
	}

	CountingSort(N, 10000);

	printf("%d", B[0]);
	for (int i = 1; i < N; i++)
	{
		printf(" %d", B[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 18804
#include<stdio.h> 
int main(){
	int p[25],c,i,s=0,j;
	scanf("%d",&c);
	for(i=0;i<c;i++){
		scanf("%d",&p[i]);
	}
	for(i=1;i<c-1;i++){
		if(p[i-1]<p[i]&&p[i]<p[i+1]){
			s++;
		}
		else if(p[i-1]>p[i]&&p[i]>p[i+1])
		{
			s++;
		}			
	}
	printf("%d\n",s);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	int A, B, sum, sub, mult;
	cin >> A >> B;
	sum = A + B;
	sub = A - B;
	mult = A * B;
	if (sum >= sub && sum >= mult) {
		cout << sum << endl;
	}
	else if (sub >= sum && sub >= mult) {
		cout << sub << endl;
	}
	else {
		cout << mult << endl;
	}
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ps = readLine()!!.split(" ").map { it.toInt() }
    var cnt = 0
    for (i in (1 until n - 1)) {
        if (ps[i] == arrayOf(ps[i-1], ps[i], ps[i+1]).sorted()[1]) cnt++
    }
    print(cnt)
}

Measured memory_bytes: 36204
#include <bits/stdc++.h>
using namespace std;
const double inf=1e10;
struct cir
{
	int x;double d;
	bool operator<(const cir &a)const{return d>a.d;}
};
cir mak(int xx,double dd){cir cc;cc.x=xx;cc.d=dd;return cc;}
double dis(double xx,double yy){return sqrt(xx*xx+yy*yy);}
int n,x[1005],y[1005],r[1005];
double c[1005][1005],dist[1005];
priority_queue<cir>pq;
int main()
{
	scanf("%d%d%d%d%d",&x[0],&y[0],&x[1],&y[1],&n);x[n+1]=x[1];y[n+1]=y[1];
	for(int i=1;i<=n;i++)scanf("%d%d%d",&x[i],&y[i],&r[i]);
	for(int i=0;i<n+1;i++)for(int j=i+1;j<=n+1;j++)c[i][j]=c[j][i]=max(0.0,dis(x[i]-x[j],y[i]-y[j])-r[i]-r[j]);
	fill(dist,dist+n+2,inf);dist[0]=0;
	pq.push(mak(0,0));
	while(!pq.empty())
	{
		cir cc=pq.top();pq.pop();
		for(int i=0;i<=n+1;i++)if(dist[i]>cc.d+c[cc.x][i])dist[i]=cc.d+c[cc.x][i],pq.push(mak(i,dist[i]));
	}
	printf("%.12f\n",dist[n+1]);
}

Measured memory_bytes: 14320
n = int(input())
a = list(map(int, input().split()))

c4 = 0
c2 = 0
for i in a:
    if i % 4 == 0:
        c4 += 1
    elif i % 2 == 0:
        c2 += 1

if n - c4 - c2 <= c4:
    print('Yes')
elif n - c4 - c2 - 1 <= c4 and c2 == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 85052
#include <iostream>
#include <string>
#include<algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;
int main()
{
	int h, w,count=0;
	cin >> h >> w;
	string s[50];
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	for (int i = 1; i < h - 1; i++) {
		for (int j = 1; j < w - 1; j++) {
			if (s[i][j] == '.') {
				for (int k = i - 1; k < i + 2; k++) {
					for (int l = j - 1; l < j + 2; l++) {
						if (s[k][l] == '#') count++;
					}
				}
				s[i][j] = '0'+count;
				count = 0;
			}
		}
	}
	for (int i = 1; i < h - 1; i++) {
		if (s[i][0] == '.') {
			for (int k = i - 1; k < i + 2; k++) {
				if (s[k][0] == '#') count++;
				if (s[k][1] == '#') count++;
			}
			s[i][0] = '0' + count;
			count = 0;
		}
		if (s[i][w-1] == '.') {
			for (int k = i - 1; k < i + 2; k++) {
				if (s[k][w-1] == '#') count++;
				if (s[k][w-2] == '#') count++;
			}
			s[i][w-1] = '0' + count;
			count = 0;
		}
	}
	for (int i = 1; i < w - 1; i++) {
		if (s[0][i] == '.') {
			for (int k = i - 1; k < i + 2; k++) {
				if (s[0][k] == '#') count++;
				if (s[1][k] == '#') count++;
			}
			s[0][i] = '0' + count;
			count = 0;
		}
		if (s[h-1][i] == '.') {
			for (int k = i - 1; k < i + 2; k++) {
				if (s[h-1][k] == '#') count++;
				if (s[h-2][k] == '#') count++;
			}
			s[h-1][i] = '0' + count;
			count = 0;
		}
	}
	if (s[0][0] == '.') {
		if (s[0][1] == '#') count++;
		if (s[1][0] == '#') count++;
		if (s[1][1] == '#') count++;
		s[0][0] = '0' + count;
		count = 0;
	}
	if (s[h-1][0] == '.') {
		if (s[h-1][1] == '#') count++;
		if (s[h-2][0] == '#') count++;
		if (s[h-2][1] == '#') count++;
		s[h-1][0] = '0' + count;
		count = 0;
	}
	if (s[0][w-1] == '.') {
		if (s[0][w-2] == '#') count++;
		if (s[1][w-1] == '#') count++;
		if (s[1][w-2] == '#') count++;
		s[0][w-1] = '0' + count;
		count = 0;
	}
	if (s[h-1][w - 1] == '.') {
		if (s[h-1][w - 2] == '#') count++;
		if (s[h-2][w - 1] == '#') count++;
		if (s[h-2][w - 2] == '#') count++;
		s[h-1][w - 1] = '0' + count;
		count = 0;
	}
	for (int i = 0; i < h; i++) {
		cout << s[i] << endl;
	}
    return 0;
}

Measured memory_bytes: 256
include Math
define_method :max, 		-> (a,b) { a > b ? a : b }
define_method :min, 		-> (a,b) { a < b ?  a : b }
define_method :swap, 		-> (a,b) { a, b = b, a }
define_method :gi, 			-> () { gets.split.map(&:to_i) }
define_method :gs, 			-> () { gets.chomp }
define_method :fi, 			-> () {first}
define_method :darray,	-> (size1, size2, init = nil) { Array.new(size1){Array.new(size2){init}} }
define_method :array,		-> (size,init = nil) { Array.new(size){init} }
define_method :putall, 	-> (obj) { obj.each { |o| puts o } }
define_method :repl, 		-> (st,en, &block) { st.upto en-1 do |i| block.call(i) end }
define_method :rep, 		-> (num, &block) { num.times do |i| block.call(i) end }

		a,b,c,d = gi
		puts max(a*b,c*d)

Measured memory_bytes: 1788