akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#include <stdio.h>
#include <map>
#include <iomanip>
#include <sstream>
//#include <boost/math/common_factor_rt.hpp>
#include<fstream>
#define EPS (1e-7)
using namespace std;
#define ll long long



class Employee {
public:
	int id;
	int parent;
	vector<int> children;
	int salary;

	Employee() {
		
	}

	Employee(int num, int nparent) {
		id = num;
		parent = nparent;
		salary = -1;
	}



};



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;
	cin >> N;

	vector<vector<int>> abc(N);
	vector<int> inner(3);
	vector<vector<int>> cost(N + 1);

	for (auto i = 0; i < N; i++)
	{
		cin >> inner[0] >> inner[1] >> inner[2];
		abc[i] = inner;
	}

	for (auto& i : inner) {
		i = 0;
	}
	for (auto i = 0; i < N+1; i++)
	{
		cost[i] = inner;
	}


	for (auto i = 0; i < N; i++) {

		for (auto j = 0; j < 3; j++) {
			for (auto k = 0; k < 3; k++) {
				if (j != k) {
					chmax(cost[i + 1][j], cost[i][k] + abc[i][j]);
				}
			}
		}

	}

	cout << max(cost[N][0], max(cost[N][1], cost[N][2])) << endl;

	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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(){
    int n, d;
    cin >> n >> d;
    int ans = n / (2*d + 1) + (n % (2*d + 1) != 0);
    cout << ans << endl;
}

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

#define MOD (1000000007LL);

using namespace std;


int main(void){
    int N;
    cin >> N;
    int M = 1000000;
    int ans = 0;
    for(int i = 0; i < N; i++){
        int P;
        cin >> P;
        if(M >= P){
            ans++;
            M = P;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],j=0,b[n+1]={};
	for(int i=1;i<=n;i++) cin>>a[i];
	b[2]=abs(a[1]-a[2]);
	for(int i=3;i<=n;i++){
		b[i]=min(abs(a[i-1]-a[i])+b[i-1],b[i-2]+abs(a[i-2]-a[i]));
	}
	cout<<b[n];
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT cin.tie(0); ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll D;
    cin >> D;

    cout << "Christmas ";
    D -= 22;
    D = abs(3 - D);

    rep(i, D) { cout << "Eve "; }
    cout << endl;


    return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// vector<int>().swap(v);清空释放内存
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-10;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
#define rep(i,be,en) for (int i=be;i<=en;i++)
#define per(i,be,en) for (int i=en;i>=be;i--)
using namespace std;
const int N=1e6+7;

int t,n,m,k=0,fl=0;
int a[N]={0};
int main(){
    scanf("%d",&m);
    rep(i,2,m){
        scanf("%d",&k);
        a[k]++;
    }
    rep(i,1,m){
        printf("%d\n",a[i]);
    }


    return 0;
}

Measured memory_bytes: 3856
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int X, N, T; cin >> X >> N >> T;
    int cnt = 0, k = 0;
    while(cnt < X){
    	cnt += N;
    	k++;
    }
    cout << k * T;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int w, h;
int xg, yg, xs, ys;
int data[102][102];
int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};
bool dfs(int, int, int);

main(){
  int c, d, x, y;
  while(1){
    cin >> w >> h;
    if(w==0 && h==0) break;
    int n;
    cin >> xs >> ys >> xg >> yg >> n;
    for(int i=0;i<h+2;i++){
      for(int j=0;j<w+2;j++){
	data[i][j]=0;
      }
    }
    for(int i=0;i<n;i++){
      cin >> c >> d >> x >> y;
      int tw, th;
      if(d==0){
	tw=4;
	th=2;
      }else{
	tw=2;
	th=4;
      }
      for(int i=0;i<=th-1;i++){
	for(int j=0;j<=tw-1;j++){
	  data[y+i][x+j]=c;
	}
      }
    }
    if(dfs(ys, xs, data[ys][xs])) cout << "OK" << endl;
    else cout << "NG" << endl;
  }
  return 0;
}

bool dfs(int y, int x, int c){
  if(c==0 || data[y][x]!=c) return false;
  if(y==yg && x==xg) return true;
  data[y][x]=0;
  for(int i=0;i<4;i++){
    if(dfs(y+dy[i], x+dx[i], c)) return true;
  }
  return false;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int a, b, c, d, e;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;
	cout << min(min(a, b), c) + min(d, e) - 50 << endl;
}





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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

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

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

    int* B;
    NEW(B,N);
    for(int i=0;i<N;i++){
        scanf("%d\n", &B[i]);
    }

    int* C;
    NEW(C,N);
    for(int i=0;i<N-1;i++){
        scanf("%d", &C[i]);
    }

    //料理を食べた時の総満足度
    int sum=0;
    for(int i=0;i<N;i++){
        sum+=B[i];
    }

    //得られるボーナス満足度
    int bonus=0;
    for(int i=0;i<N-1;i++){
        if(A[i+1]==A[i]+1){
            bonus+=C[A[i]-1];
        }
    }

    int ans=sum+bonus;

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

    return 0;
}

//200点

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

using namespace std;
#define taskname ""
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 55;
ll a[maxn] , mp , mn;
int n;
vector<pair<int,int>> v;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen(taskname".INP", "r",stdin);
	//freopen(taskname".OUT", "w",stdout);
    cin >> n;
    mp = -1e6 - 1;mn = 1e6 + 1;
    for(int i = 1 ; i <= n ;++i)
    {
        cin >> a[i];
        mp = max(mp , a[i]);
        mn = min(mn , a[i]);
    }
    if(mp >= abs(mn))
    {
        int j = 1;
        for(int i = 1 ; i <= n ; ++i)
            if(a[i] == mp)j = i;
        for(int i = 1 ; i <= n ; ++i)
        {
            if(i == j)continue;
            a[i] += mp;
            v.pb({j , i});
        }
    }
    else {
        int j = 1;
        for(int i = 1 ; i <= n ; ++i)
            if(a[i] == mn)j = i;
        for(int i = 1 ; i <= n ; ++i)
        {
            if(i == j)continue;
            a[i] += mn;
            v.pb({j , i});
        }
    }
    if(a[1] >= 0)
    {
        cout << v.size() + n - 1 << '\n';
        for(auto c : v)cout << c.first << " " << c.second << '\n';
        for(int i = 1 ; i < n ; ++i)cout << i << " " << i + 1 << '\n';
    }
    else
    {
        cout << v.size() + n - 1 << '\n';
        for(auto c : v)cout << c.first << " " << c.second << '\n';
        for(int i = n ; i > 1 ; --i)cout << i << " " << i - 1 << '\n';
    }
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
///////////////////////////


ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll n){
    return po(n,i_5);
}


#define N 2000004
ll kai[N];
ll kai2[N];
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n==0)return 1;
    return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}
int main(){fastio
    calc();
    ll x,y;cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;return 0;
    }
    ll n=(x+y)/3;
    if(x<n||y<n){
        cout<<0<<endl;return 0;
    }
    cout<<comb(n,x-n)<<endl;
    
    
    return 0;
}


Measured memory_bytes: 31488
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f

let util = ABC(stdin)

let N = util.Scan1 int
let Xs = util.ScanVecH int |> Array.sort

printfn "%d" <| Xs.[N/2] - Xs.[N/2 - 1]

Measured memory_bytes: 21212
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef vector<VB> VBB;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}


// g++ -std=c++11 prac.cpp

bool func(string s){
  string t(s.rbegin(), s.rend());
  return s==t;
}

int main() {
  ll z=0,k,n,m,h,w,ans=0,sum=0,Max=1,Min=1e9+1;
  bool ok = false;
  string s,t,r;
  cin >> s;
  n = s.size();
  if(func(s) && func(s.substr(0,(n-1)/2)) && func(s.substr((n+1)/2))){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
typedef long long int integer;

const int NMAX = 1299800;
bool isprime[NMAX];

int main() {
  vector<integer> primes;
  set<int> prime_set;
  for (int i = 0; i < NMAX; i++) {
    isprime[i] = true;
  }
  isprime[0] = isprime[1] = false;
  for (integer n = 2; n < NMAX; n++) {
    if (!isprime[n]) continue;
    primes.push_back(n);
    prime_set.insert(n);
    integer m = 2 * n;
    while (m < NMAX) {
      isprime[m] = false;
      m += n;
    }
  }

  int n;
  while (cin >> n && n) {
    if (n <= 2 or prime_set.find(n) != prime_set.end()) {
      cout << 0 << endl;
    } else {
      auto upper = upper_bound(primes.begin(), primes.end(), n);
      auto lower = lower_bound(primes.begin(), primes.end(), n) - 1;
      cout << (*upper) - (*lower) << endl;
    }
  }
}

Measured memory_bytes: 7776
import numpy as np
flag = True
N, M = map(int, input().split())
ans = 0
for i in range(1, int(np.sqrt(M)) + 2):
    if M % i == 0:
        if min(M // i, i) >= N:
            ans = max(ans, max(M // i, i))
        elif max(M // i, i) >= N:
            ans = max(ans, min(M // i, i))

print(ans)


Measured memory_bytes: 12944
<?php
  $kyori = 0;	
  $bound = 1;
  fscanf(STDIN,"%d%d",$n,$x);
  $input = preg_split("/ /",trim(fgets(STDIN)));
  for($i=0;$i<$n;$i++){
    $kyori += $input[$i];
    if($kyori>$x){
      break;
    }else{
      $bound++;
    }
  }
  echo($bound);
  ?>

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

long f0(long k) {
	if (k % 4 == 3) return 0;
	if (k % 4 == 0) return k;
	if (k % 4 == 1) return 1;
	if (k % 4 == 2) return k ^ 1;
}

int main() {
	long A, B;
	cin >> A >> B;
	if (A == 0) {
		cout << f0(B) << endl;
		return 0;
	}
	cout << (f0(A - 1) ^ f0(B)) << endl;
	return 0;
}

Measured memory_bytes: 256
import collections
n,k=map(int,input().split())
a=list(map(int,input().split()))

c=collections.Counter(a)
values = sorted(c.values())

ans=0
sum_values=len(values)
for i in range(len(values)):
    if sum_values<=k:
        break
    else:
        sum_values-=1
        ans+=values[i]
print(ans)

Measured memory_bytes: 32556
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		FastScanner sc = new FastScanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int cnt = 0;
		for(int x = 0 ; x <= k ; x++) {
			for(int y = 0 ; y <= k ; y++) {
				if((x + y) <= s && s - (x + y) <= k) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if(hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}


Measured memory_bytes: 21204
#include<cstdio>
#include<algorithm>
using namespace std;
int a[100005];

int main()
{
  int n; scanf("%d", &n);
  for(int i=1;i<=n;i++) scanf("%d", &a[i]);
  int ans=0;
  for(int i=1;i<=n;i++)
  {
     if(a[a[i]]==i) ans++;
  }
  printf("%d\n", ans/2);
  return 0;
}


Measured memory_bytes: 512
Nu,A,B = map(int, input().split())
ans = 0
for j in range(0,10):
    for k in range(0,10):
        for l in range(0,10):
            for m in range(0,10):
                if A <= j+k+l+m <= B:
                    num = j*1000 + k*100 + l*10 + m
                    if num <= Nu:
                        ans+=num

if A == 1 and Nu ==10000:
    ans += 10000

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
int a[1000][1000];
int net[2000000][2];
//main
signed main(){
  int N;cin>>N;
  memset(net,-1,sizeof(net));
  for(int i=0;i<N;i++)for(int j=1;j<N;j++){int k;cin>>k;k--;a[i][j]=k;}
  for(int i=0;i<N;i++){
    for(int j=2;j<N;j++){
      int s=i,t=a[i][j];if(s>t)swap(s,t);
      int res=s*1000+t;
      int ss=i,tt=a[i][j-1];if(ss>tt)swap(ss,tt);
      int res2=ss*1000+tt;
      if(net[res][0]==-1)net[res][0]=res2;
      else if(net[res][0]!=res2)net[res][1]=res2;
    }
  }
  std::vector<int> in(2000000,0);
  for(int i=0;i<2000000;i++)for(int j=0;j<2;j++)if(net[i][j]!=-1)in[net[i][j]]++;
  queue<int> que;
  for(int i=0;i<2000000;i++){
    int s=i/1000,t=i%1000;if(s>=t)continue;if(s>=N||t>=N)continue;//cout<<"I"<<i<<endl;
    if(in[i]==0)que.push(i);//cout<<in[i]<<endl;
  }
  std::vector<int> used(2000000,-1),pused(1000,-1);int cnt=0;
  int ans=0;//cout<<que.size()<<endl;
  if(que.size()==0)fin(-1);
  while(que.size()){
    int p=que.front();que.pop();
    //cout<<"P"<<p<<endl;
    if(~used[p])fin(-1);used[p]=1;cnt++;
    int s=p/1000,t=p%1000;
    if(pused[s]!=-1||pused[t]!=-1){
      ans++;
      fill(pused.begin(),pused.end(),-1);
    }
    pused[s]=pused[t]=1;
    if(net[p][0]!=-1)if(--in[net[p][0]]==0)que.push(net[p][0]);
    if(net[p][1]!=-1)if(--in[net[p][1]]==0)que.push(net[p][1]);
  }
  if(cnt<N*(N-1)/2)fin(-1);
  fin(ans+1);
}


Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RSORT(obj) sort((obj).begin(), (obj).end(), greater<>())


ll  x , y , a , b , c;


void solve( ) {
	cin >> x >> y >> a >> b >> c;
	vector<int> r( a ) , g( b ) , rg( c );
	rep( i , a )cin >> r[ i ];
	rep( i , b )cin >> g[ i ];
	rep( i , c )cin >> rg[ i ];
	RSORT( r );
	RSORT( g );
	rep( i , x ) rg.push_back( r[ i ] );
	rep( i , y ) rg.push_back( g[ i ] );
	RSORT( rg );
	ll ans=0;
	rep( i , x + y )ans += rg[ i ];
	cout << ans;

}


signed main( ) {
	solve( );
	return 0;
}


Measured memory_bytes: 2552
n = gets.to_i
n.times do
  tubeB = []
  tubeC = []

  balls = gets.chomp.split(" ")
  balls.each_with_index do |b, i|
    b = b.to_i

    topB = tubeB[tubeB.length - 1] || 0
    topC = tubeC[tubeC.length - 1] || 0

    if topB < b
      tubeB.push(b)
    elsif topC < b
      tubeC.push(b)
    else
      puts "NO"
      break
    end

    if i == balls.length - 1
      puts "YES"
    end
  end
end

Measured memory_bytes: 6100
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();


    void Solve()
    {
        long N = cin.Nextlong;
        long a = 1;
        int ans = 0;
        while (a * 2 <= N + 1)
        {
            a *= 2;
            ans++;
        }
        
        Console.WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}


Measured memory_bytes: 9244
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    int flag=false;
    for(int i=0;i<a.size();i++){
        if(a[i]=='C')
        flag=true;  
        if(a[i]=='F'&&flag==true){
            cout<<"Yes";
            return 0;
        }
    } 
    cout<<"No"<<endl;  
    return 0;
}
           

Measured memory_bytes: 256
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){var t=e.split(" ");Number(t[0])%Number(t[1])==0?console.log(0):console.log(1)}},function(e,t){e.exports=require("fs")}]);

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

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<char> alp(0);
	for (char c = 'a'; c <= 'z'; c++) { alp.push_back(c); }
	for (char c = 'A'; c <= 'Z'; c++) { alp.push_back(c); }
	int n; while ( cin >> n && n != 0 )
	{
		vector<int> dat(n + 2, 0);
		rep(i, n) { cin >> dat[i]; }
		string str; cin >> str;
		int lp1 = 0, lp2 = 0;
		while (1)
		{
			if (lp1 == n) { lp1 = 0; }
			if (lp2 == (int)str.size()) { break; }
			cout << alp[(find(all(alp), str[lp2]) - alp.begin() - dat[lp1] + alp.size()) % alp.size()];
			lp1++; lp2++;
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;
int n, height[100001], k;
ll cost[100001];

ll findCost(int n){
	if(cost[n] != -1)
		return cost[n];
	ll d = INT_MAX;
	for(int i = max(0, n - k); i < n; ++i)
		d = min(findCost(i) + abs(height[n] - height[i]), d);
	return cost[n] = d;
}

ll solve(){
	mem(cost, -1);
	cost[1] = 0;
	cost[2] = abs(height[2] - height[1]);
	return findCost(n);
}

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n >> k;
	for(int i = 1; i <= n; ++i){
		cin >> height[i];
	}

	cout << solve();
	return 0;
}

Measured memory_bytes: 10948
#include <iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	int count=0,len=s.size();;
	for(int i=0;i<len/2;++i){
		if(s[i]=='('&&s[len-i-1]==')') continue;
		else if(s[i]==')'&&s[len-i-1]=='(') continue;
		else if(s[i]=='('&&s[len-i-1]=='(') ++count;
		else if(s[i]==')'&&s[len-i-1]==')') ++count;
		else if(s[i]!=s[len-i-1]) ++count;
	}
	if(len%2&&(s[len/2]=='('||s[len/2]==')'))++count;
	cout<<count<<endl;
	return 0;
}

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


int main() {
  int K,A,B;
  cin >> K >> A >> B;
  bool  b = false;
  for(int i = 0; i < 10000; i++) {
    if(i*K >= A && i*K <= B) {
      b = true;
      break;
    }
  }
  if(b) cout<<"OK"<<endl; 
  else cout<<"NG"<<endl; 
}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }


int N;
int n, m;
int fi[25][25];
int now[(1<<20)+10], next[(1<<20)+10];

int main() {
    //freopen( "/Users/macuser/Dropbox/Contest/input.in", "r", stdin );
    cin >> N;
    for (int it = 0; it < N; ++it) {
        cin >> m >> n;
        for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin >> fi[i][j];
        memset(now, -1, sizeof(now));
        memset(next, -1, sizeof(next));
        
        int res = 0;
        now[0] = 0;
        for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
            memset(next, -1, sizeof(next));
            for (int bit = 0; bit < (1<<m); ++bit) {
                if (now[bit] == -1) continue;
                chmax(next[bit&~(1<<j)], now[bit]);
                if ( !(bit & (1<<j)) && (j == 0 || !(bit & (1<<(j-1)))) ) chmax(next[bit|(1<<j)], now[bit] + fi[i][j]);
            }
            for (int bit = 0; bit < (1<<m); ++bit) { 
                now[bit] = next[bit]; 
                chmax(res, now[bit]); 
                //cout << i << ", " << j << ", " << bitset<3>(bit) << " : " << now[bit] << endl;
            }
        }
        
        cout << "Case " << it+1 << ": " << res << endl;
    }
    return 0;
}


Measured memory_bytes: 9360
# Edige Weighted Digraph


from collections import namedtuple


WeightedEdge = namedtuple('WeightedEdge', ('src', 'dest', 'weight'))


class Digraph:
    def __init__(self, v):
        self.v = v
        self._edges = [[] for _ in range(v)]

    def add(self, edge):
        self._edges[edge.src].append(edge)

    def adj(self, v):
        return self._edges[v]

    def edges(self):
        for es in self._edges:
            for e in es:
                yield e


def mca_chu_liu_edmonds(graph, s):
    def select_edges():
        es = [None] * graph.v
        for v in range(graph.v):
            for e in graph.adj(v):
                w = e.dest
                if w == s:
                    continue
                if es[w] is None or e.weight < es[w].weight:
                    es[w] = e
        return es

    def find_cycle(es):
        vs = [0 for _ in range(graph.v)]
        for e in es:
            if e is None:
                continue
            vs[e.src] += 1
        leaves = [v for v, c in enumerate(vs) if c == 0]
        while leaves:
            leaf, *leaves = leaves
            if es[leaf] is not None:
                w = es[leaf].src
                vs[w] -= 1
                if vs[w] == 0:
                    leaves.append(w)
        cycle = []
        for v, c in enumerate(vs):
            if c > 0:
                cycle.append(v)
                u = es[v].src
                while u != v:
                    cycle.append(u)
                    u = es[u].src
                break
        return cycle

    def contract(es, vs):
        vvs = []
        vv = 0
        c = graph.v - len(vs)
        for v in range(graph.v):
            if v in vs:
                vvs.append(c)
            else:
                vvs.append(vv)
                vv += 1
        g = Digraph(c+1)
        for v in range(graph.v):
            for e in graph.adj(v):
                if e.src not in vs or e.dest not in vs:
                    v = vvs[e.src]
                    w = vvs[e.dest]
                    weight = e.weight
                    if e.dest in vs:
                        weight -= es[e.dest].weight
                    e = WeightedEdge(v, w, weight)
                    g.add(e)
        return g, vvs[s]

    edges = select_edges()
    cycle = find_cycle(edges)

    if cycle:
        g, ss = contract(edges, cycle)
        return mca_chu_liu_edmonds(g, ss) + sum(edges[v].weight for v in cycle)
    else:
        return sum(e.weight for e in edges if e is not None)


def run():
    v, e, r = [int(i) for i in input().split()]
    graph = Digraph(v)

    for _ in range(e):
        s, t, w = [int(i) for i in input().split()]
        graph.add(WeightedEdge(s, t, w))

    print(mca_chu_liu_edmonds(graph, r))


if __name__ == '__main__':
    run()



Measured memory_bytes: 8708
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var XY = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (X, Y) = (XY[0], XY[1]);

        var ans = X + Y / 2;

        WriteLine(ans);
    }
}


Measured memory_bytes: 28196
N,M = map(int,input().split())
student = [list(map(int,input().split())) for i in range(N)]
point = [list(map(int,input().split())) for j in range(M)]

for i in range(N):
    student_x = student[i][0]
    student_y = student[i][1]
    distance = []
    for j in range(M):
        point_x = point[j][0]
        point_y = point[j][1]
        distance.append(abs(student_x - point_x) + abs(student_y - point_y))
    distance_min = min(distance)
    n = 0
    while True:
        if distance_min == distance[n]:
            print(n+1)
            break
        else:
            n += 1


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N,K;
    cin >> N >> K;

    vector<i64> t(N),d(N);
    rep(i,0,N){
        cin >> t[i] >> d[i];
    }
    
    map<i64,vector<i64>> mp;
    rep(i,0,N){
        mp[t[i]].emplace_back(d[i]);
    }
    
    vector<i64> first,other;
    for(auto& p:mp){
        auto& v=p.second;
        sort(rbegin(v),rend(v));
        
        first.emplace_back(v.front());
        rep(i,1,v.size()){
            other.emplace_back(v[i]);
        }
    }
    
    sort(rbegin(first),rend(first));
    sort(rbegin(other),rend(other));
    
    i64 ans=0;
    rep(i,0,first.size()){
        i64 x=i+1,sumd=0;

        if(K-x>other.size()) continue;

        rep(j,0,x){
            sumd+=first[j];
        }
        rep(j,0,K-x){
            sumd+=other[j];
        }

        ans=max(ans,sumd+x*x);
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 13944
n=list(input())
n.reverse()
lb,ub=0,len(n)
def check(x):
	g=0
	for i in n:
		x-=(x+g-int(i))%10
		if x<0:
			break
		g=(x+g)//10
	return x>=0
while ub-lb>1:
	mid=(lb+ub)//2
	if check(9*mid):
		ub=mid
	else:
		lb=mid
print(ub)

Measured memory_bytes: 89980
my $N = <STDIN>;
chomp $N;
if ($N % 2) {
    print "No";
    exit;
}
my $S = <STDIN>;
chomp $S;
my $m = $N / 2;
my $T = substr($S, 0, $m);
if ($S eq $T.$T) {
    print "Yes";
} else {
    print "No";
}


Measured memory_bytes: 512
let () = Scanf.scanf "%d %d %d\n" @@ fun n m c ->
  let bs = Array.to_list @@ Array.init m @@ fun _ -> Scanf.scanf "%d " @@ fun b -> b in
  let ass = Array.to_list @@ Array.init n @@ fun _ ->
    Array.to_list @@ Array.init m @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  Printf.printf "%d\n" @@
    List.length @@
    List.filter (( < ) 0) @@
    List.map (List.fold_left2 (fun a b c -> a + b * c) c bs) ass


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

int main(){

  long long N, X, num_all=1, num_patty=1, ans=0;
  bool bigX;
  cin >> N >> X;
  for(int i=0; i<N; i++) num_all = 2*num_all + 3;
  for(int i=0; i<N; i++) num_patty = 2*num_patty + 1;

  while(1){
    bigX = X > (num_all+1)/2 ? true : false ;
    if(X == (num_all+1)/2){
      ans += (num_patty+1)/2;
      break;
    }else if(X == num_all){
      ans += num_patty;
      break;
    }else if(X == 1){
      break;
    }else if(bigX){
      X -= (num_all+1)/2;
      ans += (num_patty+1)/2;
      num_all = (num_all-3)/2;
      num_patty = (num_patty-1)/2;
    }else{
      X -= 1;
      num_all = (num_all-3)/2;
      num_patty = (num_patty-1)/2;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
  static int n, k, x, y;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt(); k = sc.nextInt();
    x = sc.nextInt(); y = sc.nextInt();

    int sum = 0;
    if(n <= k){
      sum += n * x;
      System.out.println(sum);
      return;
    }

    sum += k * x;
    sum += y * (n - k);

    System.out.println(sum);
  }
}

Measured memory_bytes: 9940
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <unordered_map>
using namespace std;


int main() {
	int a,b;
	while (1) {
		cin >> a >>b;
		if (a==0 && b==0)
			break;
		if (a > b)
			cout << b << " " << a << endl;
		else
			cout << a << " " << b << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    REP(i, n){
        cin >> v[i];
    }
    ll sum = 0;
    REP(i, n){
        ll b;
        cin >> b;
        v[i] -= b;
        sum += v[i];
    }
    if(sum < 0){
        cout << -1 << endl;
        return 0;
    }
    vector<ll> u;
    sum = 0;
    int count = 0;
    REP(i, n){
        if(v[i] < 0){
            sum += v[i];
            count++;
        }else if(v[i] > 0){
            u.push_back(v[i]);
        }
    }
    sort(u.rbegin(), u.rend());
    int i = 0;
    while(sum < 0){
        sum += u[i];
        i++;
    }
    cout << i + count << endl;

    return 0;
}

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

int main(){
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if(u == s) a--;
  else b--;
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
/*
P135
AOJ 2249 Road Construction
Difficult: 4
*/

#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <functional>
#include <string.h>
#include <cmath>

using namespace std;

const int MAXN = 10100;
const int INF = 1<<30;
struct Edge{
    int v, d, c;
    Edge(){}
    Edge(int _v, int _d, int _c):v(_v),d(_d),c(_c){}
};

vector<vector<Edge> > graph;

int M, N;

bool read()
{
    scanf("%d%d", &N, &M);
    if(N==0 && M==0) return false;
    graph.clear();
    graph.resize(N);
    int s, e, d, c;
    for(int i=0; i<M; ++i){
        scanf("%d%d%d%d", &s, &e, &d, &c);
        --s, --e;
        graph[s].push_back(Edge(e,d,c));
        graph[e].push_back(Edge(s,d,c));
    }
    return true;
}

int dist[MAXN];
int cost[MAXN];
bool inq[MAXN];

void spfa(int src, int dis[])
{
    queue<int> q;
    for(int i=0; i<N; ++i)
        dis[i] = INF, inq[i] = false;
    dis[src] = 0;
    cost[src] = 0;
    q.push(src);
    inq[src] = true;
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int i=0; i<graph[u].size(); i++){
            int v = graph[u][i].v;
            int d = graph[u][i].d;
            int c = graph[u][i].c;
            if( dist[v] > dist[u] + d ){
                dist[v] = dist[u] + d;
                cost[v] = c;
                if(!inq[v]) {
                    q.push(v);
                    inq[v] = true;
                }
            }
            else if( dist[v] == dist[u] + d)
                cost[v] = min(cost[v], c);
        }
        inq[u] = false;
    }
}

void solve()
{
    spfa(0, dist);
    int ans = 0;
    for(int i=0; i<N; ++i){
        ans += cost[i];
    }
    printf("%d\n", ans);
}

int main()
{
    while(read())
    solve();
}

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

int main()
{
    int sum = 0;
    string X;
    cin >> X;
    for (int i = 0; i < X.size(); i++)
    {
        int temp = X[i] - '0';
        sum += temp;
    }

    if (stoi(X) % sum == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String readStr;
    
    int numOfVertialLine = Integer.parseInt(reader.readLine());
    int[] verticalLines = new int[numOfVertialLine];
    for (int i = 1; i <= verticalLines.length; i++)
      verticalLines[i-1] = i;
    
    int numOfChange = Integer.parseInt(reader.readLine());
    for (int i = 0; i < numOfChange; i++) {
      String[] changeStr = reader.readLine().split(",");
      int from = Integer.parseInt(changeStr[0]);
      int to = Integer.parseInt(changeStr[1]);
      int from_stack = verticalLines[from-1];
      verticalLines[from-1] = verticalLines[to-1];
      verticalLines[to-1] = from_stack;
    }
    
    for (int n : verticalLines)
      System.out.println(n);
    
  }

}

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

void solve()
{
  string a;
  cin>>a;
  if(a[2]==a[3]&&a[4]==a[5]){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

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

        solve();

    return 0;
}



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

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

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
const int N = 1e5+5;
int dp[N];
vector<int> G[N];

int func(int s){
	if(SZ(G[s]) == 0)	return 0;
	if(dp[s]!=0)	return dp[s];
	rep(i,SZ(G[s])){
		if(!dp[G[s][i]])	dp[G[s][i]] = func(G[s][i]);
		dp[s] = max(dp[s],dp[G[s][i]]+1);
	}
	return dp[s];
}


signed main(){
	IOS
	int n,m;	cin >> n >> m;
	rep(i,m){
		int s,t;	cin >> s >> t;
		G[t].pb(s);
	}
	int ans = 0;
	rep(i,n){
		func(i+1);
		// cout << dp[i+1] << ' ';
		ans = max(ans,dp[i+1]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 10752
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

/*
- x
  - a
- y
  - b
- z
  - c
a = (x + y) / 2
=> y = 2a - x
b = (y + z) / 2
=> z = 2b - y => z = 2b - 2a + x
c = (z + x) / 2
=> x = 2c - z => x = 2c - 2b + 2a - x
=> x = a - b + c
*/
fn main() {
    let N: usize = read();
    let mut A: Vec<usize> = (0..N).map(|_| read()).collect();
    let mut ans: Vec<usize> = vec![];
    let mut firstVal: i32 = 0;
    for (i, &v) in A.iter().enumerate() {
        if i % 2 == 0 {
            firstVal += v as i32;
        } else {
            firstVal -= v as i32;
        }
    }
    A.pop();
    ans.push(firstVal as usize);
    for dam in A {
        let now = ans[ans.len() - 1];
        let next = (dam - (now as usize / 2)) * 2;
        ans.push(next);
    }
    println!(
        "{}",
        ans.into_iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    )
}


Measured memory_bytes: 8604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll N, m = 0, sum = 0;
    cin >> N;
    vector<ll> P(N);
    repi(i, N, 0)
    {
        cin >> P[i];
        m = max(m, P.at(i));
    }
    repi(i, N, 0)
    {
        sum += P.at(i);
    }
    cout << sum - m / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
 
n=int(input())
w=list(map(int, input().split()))
s=[0]*n
 
for i in range(n):
  a = np.sum(w[:i+1])
  b = np.sum(w)
  c = b - a
  s[i] = abs(a-c)

print(np.min(s))

Measured memory_bytes: 12396
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define rrep(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)

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

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


//////////////////////////////////////////////////

struct Edge {
    int to;
    ll cost;
};

int main() {
    int n; cin >> n;
    vector<vector<Edge>> g(n);
    for (int i = 0; i < n-1; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        ll c; cin >> c;

        g[a].push_back(Edge{b, c});
        g[b].push_back(Edge{a, c});
    }

    int q, k; cin >> q >> k;
    k--;
    vector<pair<int, int>> xy(q);
    for (int i = 0; i < q; i++)
    {
        int x, y;
        cin >> x >> y;
        x--; y--;
        xy[i] = make_pair(x, y);
    }


    // dijk
    // sからの距離を返す
    int s = k;
    const ll inf = 1e16;
    vector<ll> dp(n, inf);
    vector<bool> visited(n, false);
    
    using P = pair<ll, int>;
    priority_queue<P, vector<P>, greater<P>> pq;
    dp[s] = 0;
    pq.push(P(0, s));

    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int now = p.second;

        if (visited[now]) continue;
        visited[now] = true;

        for (int i = 0; i < g[now].size(); i++) {
            int next = g[now][i].to;
            ll cost = g[now][i].cost;

            chmin(dp[next], dp[now] + cost);
            pq.push(P(dp[next], next));
        }
    }
    

    // for (int i = 0; i < n; i++)
    // {
    //     cout << dp[i] << endl;
    // }
    
    for (int i = 0; i < q; i++)
    {
        cout << dp[xy[i].first] + dp[xy[i].second] << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 11888
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        for(int i = 1, n = scn.nextInt(); i <= n; i++) {
            if(call(i)) {
                System.out.print(" " + i);
            }
        }
        System.out.println();
    }
    
    private static boolean call(int x) {
        boolean rslt = false;
        if(x % 3 == 0) {
            rslt = true;
        }
        for(; x > 0; x /= 10) {
            if(x % 10 == 3) {
                rslt = true;
                break;
            }
        }
        return rslt;
    }
}

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

using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

bool pallan(string s){
    ll i=0,j=s.size()-1;
    while(i<j){
        if(s[i]!=s[j])
            return false;
        i++;
        j--;
    }
    return true;
}

int main() {
    fio;
    
    ll k,n;cin>>k>>n;//>>m;
    
    ll sum=0;
    ll a[n+1];
    for(ll i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    
    if(sum>=k){
        cout<<"Yes\n";
    }
    else
        cout<<"No\n";
    
    
    
	return 0;
}

Measured memory_bytes: 1024