akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
const long double eps = 1e-12;
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
long long bunsi[200000];
long long bunbo[200000];
int main(){
	long long n, m;
	cin >> n >> m;
	REP(i, n) {
		cin >> bunsi[i];
		bunbo[i] = 1;
	}
	priority_queue<pair<long long, long long>> gogo;
	REP(i, n) {
		long long now_kane = bunsi[i];
		now_kane -= bunsi[i] / 2;
		gogo.push(make_pair(now_kane, i));
	}
	while (gogo.empty() == false && m >= 1) {
		m--;
		pair<long long, long long> now = gogo.top();
		gogo.pop();
		bunbo[now.second] *= 2LL;
		long long now_kane = bunsi[now.second] / bunbo[now.second];
		now_kane -= bunsi[now.second] / (2LL * bunbo[now.second]);
		if (now_kane != 0) {
			gogo.push(make_pair(now_kane, now.second));
		}
	}
	long long ans = 0;
	REP(i, n) {
		ans += bunsi[i] / bunbo[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3956
K=int(input())

idx=0
l=list(range(1,10))

while len(l)<K:
    m=l[idx]
    for i in (-1,0,1):
        n=(m%10)+i
        if n in{-1,10}:
            continue
        tmp=m*10+n
        l.append(tmp)
    idx=idx+1

print(l[K-1])

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

using namespace std;

int main(){

  int N;
  int K;
  string S;
  cin >> N >> K >> S;
  vector<int> vInd, vSeq;;

  int seq = 0;
  for(int i = 0; i< N; ++i){
    if(S[i] == '0'){
      ++seq;
      while(i+seq < N && S[i+seq] == '0'){
        ++seq;
      }
      vInd.push_back(i);
      vSeq.push_back(seq);
      i += seq;
      seq = 0;
    }
  }

  //  cout << endl;
  //  cout << vInd.size() << endl;

  // for(int i = 0; i< vInd.size(); ++i){
  //   cout << "  " << vInd.at(i) << "  " << vSeq.at(i) << endl;
  // }

  int ans = 0;
  int nBlank = vInd.size();
  if(nBlank < K) ans = N;
  else{
    for(int i = 0; i <= nBlank- K; ++i){
      if(i == 0){
        ans = max(ans, vInd[i+K]);
        //      cout << "  1st  " << ans <<endl;
      }

      else if(i == nBlank -K){
        ans = max(ans, N - (vInd[i-1] + vSeq[i-1]));
        //      cout << "  last " << ans <<endl;
      }
      else{
        ans = max(ans, vInd[i+K] - (vInd[i-1] + vSeq[i-1]));
        //      cout << "  " << i+1 << "th "  << ans <<endl;
      }
      //      cout << "  " << ans <<endl;
    }
  }

  cout << ans << endl;
  return 0;

}

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


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

   std::string ans;
   bool flag = false;
   int cnt = 0;
   while (1)
   {
      char a = s[s.size() - 1];
      for (int i = s.size() - 1; i >= 0; i--)
      {
         s[i] = s[i - 1];
      }

      s[0] = a;

      cnt++;

      if (s == t)
      {
         flag = true;
         break;
      }

      if(cnt == s.size() + 3) {
         flag == false;
         break;
      }

   }

   ans = flag ? "Yes" : "No";

   std::cout << ans << std::endl;
}


Measured memory_bytes: 3592
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    a, b = map(int, input().split())
    n = 0
    if a >= b + 2:
        n = a + a - 1
    elif a + 2 <= b:
        n = b + b - 1
    else:
        n = a + b
    print(n)

main()


Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
	int m,f,b,x,y,z;
	scanf("%d %d %d",&m,&f,&b);
	if(m>=b){
		printf("0\n");
	}
	else{
		x=b-m;
		if(f>=x){
			printf("%d\n",x);
		}
		else{
			printf("NA\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2764
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	A := make([]int, N+1)
	for i := 1; i <= N; i++ {
		A[i] = scanInt()
	}

	ans := make([]int, N+1)
	for i := N; i > 0; i-- {
		sum := 0
		for j := i; j <= N; j += i {
			sum += ans[j]
		}
		if sum%2 != A[i] {
			ans[i] = 1
		}
	}

	M := 0
	for _, a := range ans {
		M += a
	}
	fmt.Println(M)

	for i, a := range ans {
		if a == 1 {
			fmt.Printf("%d ", i)
		}
	}

}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int a[35],b[35];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i = 1;i <= n; ++i)
    {
        int k,v;
        cin>>k;
        while(k--)
        {
            cin>>v;
            if(!b[v])
            {
               a[v]++;
               b[v] = 1;
            }
        }
        for(int j = 1;j <= 32; ++j) b[j] = 0;
    }
    int sum = 0;
    for(int i = 1;i <= m; ++i)
    {
        if(a[i] == n) sum++;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 384
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

/*
 * 2 7 1 8 2 8
 * 7 8 2 2 8 1
 * キーとなるのは、nから4の倍数ではない2の倍数を引く.
 * 残りの半分が4の倍数であればok.
 */
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  loop(i,0,n) cin >> A[i];
  int cnt2 = 0;
  int cnt4 = 0;
  for (auto &&a: A) {
    if (a%4!= 0 and a%2==0) cnt2++;
    else if (a%4==0) cnt4++;
  }
  if (cnt2%2==0) n -= cnt2;
  else n -= cnt2 - 1;
  if (cnt4 >= n/2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main(){
    long long int N,A,B;
    cin >> N >> A >> B;

    if(A == 0){
        cout << 0;
    }
    else if(B == 0){
        cout << N;
    }
    else{
        long long int s = N/(A+B);
        long long int t = N - s*(A+B); 
        if(t<A){
            cout << s*A + t;
        }
        else{
            cout << s*A + A;
        }
    }

   cout << endl;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

if __name__ == "__main__":
    N = int(input())
    A = make_divisors(N)
    cnt = 0
    for a in A[1:]:
        n = N
        while n%a == 0:
            n = n//a
        if n%a == 1:
            cnt += 1
    print(cnt+len(make_divisors(N-1))-1)

Measured memory_bytes: 39024
N = int(input())
A = list(map(int, input().split()))

# if N == 1:
#     print(0)
#     exit()

step = 0
for i in range(N-1):
    if A[i] > A[i+1]:
        diff = A[i] - A[i+1]
        step += diff
        A[i+1] += diff

print(step)

Measured memory_bytes: 32292
// clang-format off
#include <bits/stdc++.h>

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
constexpr ll MOD = 1000000007;

constexpr int MAX = 100000;

struct Graph
{
    Graph()
    {
        rep(i, MAX){
            edge[i].clear();
        }
    }
    void insert(int a, int b)
    {
        edge[a].pb(b);
        edge[b].pb(a);
    }
    vector<int> edge[MAX];
};

constexpr int DMAX = 11;
int operation[MAX][DMAX];
int color[MAX];

int main()
{
    int N, M;
    cin >> N >> M;
    Graph g;
    rep(i, M){
        int a, b;
        cin >> a >> b;
        g.insert(a-1, b-1);
    }
    constexpr int INFI = -1;
    rep(i, MAX){
        rep(j, DMAX){
            operation[i][j] = INFI;
        }
    }

    int Q;
    cin >> Q;
    rep(i, Q){
        int v, d, c;
        cin >> v >> d >> c;
        operation[v-1][d] = i;
        color[i] = c;
    }

    for(int d = DMAX-1; d >= 1; d--){
        rep(i, N){
            if(operation[i][d] != INFI){
                chmax(operation[i][d-1], operation[i][d]);
                for(const auto e : g.edge[i]){
                    //                    assert(e < N);
                    chmax(operation[e][d-1], operation[i][d]);
                }
            }
        }
    }
    rep(i, N){
        if(operation[i][0] != INFI){
            //            assert(operation[i][0] < Q);
            cout << color[operation[i][0]] << endl;
        } else {
            cout << 0 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 11128
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cctype>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)

using namespace std;
const int N=5005,mod=1000000007;
typedef long long LL;
int n,h[N],cnt,siz[N],g[N],f[N][N],b[N],ans;
struct edge{int v,n;} e[N<<1];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

void addedge(int u,int v)
{
	e[cnt]=(edge){v,h[u]},h[u]=cnt++;
	e[cnt]=(edge){u,h[v]},h[v]=cnt++;
}

void inc(int &x,LL y)
{
	x=(x+y)%mod;
}

void dfs(int x,int fa)
{
	siz[x]=1,f[x][1]=1;
	for(int i=h[x]; i!=-1; i=e[i].n)
		if(e[i].v!=fa)
		{
			dfs(e[i].v,x);
			rep(j,0,siz[x]+siz[e[i].v]) g[j]=0;
			rep(j,1,siz[x])
				rep(k,1,siz[e[i].v])
				{
					inc(g[j+k],(LL)f[x][j]*f[e[i].v][k]);
					inc(g[j],(LL)-f[x][j]*f[e[i].v][k]%mod*b[k]);
				}
			siz[x]+=siz[e[i].v];
			rep(j,0,siz[x]) f[x][j]=g[j];
		}
}

int main()
{
	n=getint();
	memset(h,-1,sizeof(h));
	rep(i,1,n-1) addedge(getint(),getint());
	b[0]=1;
	rep(i,1,n) if(!(i&1)) b[i]=(LL)b[i-2]*(i-1)%mod;
	dfs(1,0);
	rep(i,1,n) inc(ans,(LL)f[1][i]*b[i]);
	printf("%d\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 97152
#include "bits/stdc++.h"
using namespace std;

int main(){
	int n;
	int a[]={1,2,4,8,16,32,64,128,256,512};
	while(cin>>n){
		vector<int> x;
		for(int i=0;i<10;i++){
			if(n/a[10-i-1]==1){
				//cout<<a[10-1-i]<<endl;
				n-=a[10-i-1];
				x.push_back(a[10-i-1]);
				if(n==0)break;
			}
		}
		
		for(int i=0;i<x.size()-1;i++){
			cout<<x[x.size()-1-i]<<" ";
		}
		cout<<x[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

int main()
{
	char a;
	cin >> a;

	if ('a' <= a && a <= 'z') {
		cout << "a" << endl;
	}
	else {
		cout << "A" << endl;
	}
}


Measured memory_bytes: 3564
#include <iostream>
using namespace std;
int main()
{
	int K,S;
	cin>>K>>S;
	int ans = 0;
	for(int x = 0; x <= K; ++x)
	{
		for(int y = 0; y <= K; ++y)
		{
			int z = S - x - y;
			if(0 <= z and z <= K)
			{
				ans = ans + 1;
			}
		}
	}

 cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int n, k;
    cin>>n>>k;
    if (k == 1)
        cout<<0;
    else if (k < 1)
        cout<<0;
    else if (n < 1)
        cout<<0;
    else if (n < k)
        cout<<0;
    else {
        cout<<(n-k);
    }
    return 0;
}

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

int main(){
    int N, M; cin >> N >> M;
    vector<int> p(M);
    vector<string> S(M);

    rep(i, 0, M){
        cin >> p[i] >> S[i];
        p[i]--;
    }

    vector<bool> ac(N, false);
    vector<int> cnt(N, 0);
    int ans1 = 0, ans2 = 0;

    rep(i, 0, M){
        if(ac[p[i]] == false && S[i] == "AC"){
            //cerr << 1 << endl;
            ans1++;
            ac[p[i]] = true;
            ans2 += cnt[p[i]];
        }else if(S[i] == "WA"){
            //cerr << 2 << endl;
            cnt[p[i]]++;
        }else if(S[i] == "AC"){
            //cerr << 3 << endl;
        }
    }
    cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 6784
#include <stdio.h>
int main()
{
  int D,T,S;
  double time;
  scanf("%d%d%d",&D,&T,&S);
  time = (double)D/S;
  if(time <= T){
    printf("Yes\n");
    }
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define MAXN 10000001
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};
int spf[MAXN];

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}
ll n,m;
ll c;

vector<ll> v[200001];
ll vis[200001];
void dfs(ll node){
	vis[node]=1;
	c++;

	
	for(auto i:v[node]){
		if(vis[i]==0){
			

			dfs(i);

		}
	}
}
void sieve()
{
	int i,j;
	for(i=0;i<MAXN;i++)
	spf[i]=i;
	for(i=4;i<MAXN;i+=2)
	spf[i]=2;
	for(i=3;i*i<MAXN;i++)
	{
		if(spf[i]==i)
		{
			for(j=i*i;j<MAXN;j+=i)
			{
				if(spf[j]==j)spf[j]=i;
			}
		}
	}
}

void solve(){
	
	ll n;
	cin>>n;
	  sieve();
	vector<ll> a(n),b(n);
	ll minl=INT_MAX;
	bool f=true;


	for(ll i=0;i<n;i++){
		cin>>a[i];

		//minl=min(v[i],minl);
		b[i]=a[i];



	}
	  unordered_map<ll,ll> m;
        for(ll i=0;i<n;i++)
        {
            for(ll j=2;j*j<=a[i];j++)
            {
                if(a[i]%j==0)
                {
                    if(m[j])
                    {
                        f=false;
                        break;
                    }
                    while(a[i]%j==0)
                    {
                        a[i]/=j;
                        m[j]++;
                    }
                }
            }
            if(a[i]>1)
            {
                if(m[a[i]])
                {
                    f=false;
                }
                else
                {
                    m[a[i]]++;
                }
            }
            if(f==false)break;
        }



       ll  p=__gcd(b[0],b[1]);
        for(ll i=2;i<n;i++){
            p=__gcd(p,b[i]);
        }

        if(f==true)
        {
            cout<<"pairwise coprime"<<endl;
        }
        else if(p==1)
        {
            cout<<"setwise coprime"<<endl;
            
        }
        else
         cout<<"not coprime"<<endl;








return;
}




int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    ll t;
    t=1;
   //cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 62444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		String s = fs.next();
		String t = fs.next();
		
		if(t.startsWith(s) && s.length() + 1 == t.length()) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 32608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>

using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
const ll MOD = 1e9 + 7;

int main() {
    ll N, W;
    cin >> N >> W;
    vector<vector<ll>> all(4,vector<ll>(N));
    ll w0;
    cin >> w0;
    ll v0;
    cin >> v0;
    all[0].push_back(v0);
    rep(i, N - 1) {
        ll x, y;
        cin >> x >> y;
        all[x - w0].push_back(y);
    }
    rep(i, 4) {
        sort(all[i]);
        riverse(all[i]);
    }
    vll ans;
    rep(i, all[0].size()) {
        rep(j, all[1].size()) {
            rep(k, all[2].size()) {
                rep(l,all[3].size()){
                    if (w0 * (i+j+k+l) + j+2*k+3*l <= W){
                        int value = 0;
                        rep(i1, i) value += all[0][i1];
                        rep(j1, j) value += all[1][j1];
                        rep(k1, k) value += all[2][k1];
                        rep(l1, l) value += all[3][l1];
                        ans.push_back(value);
                    }
                }
            }
        }
    }
    sort(ans);
    riverse(ans);
    cout << ans[0] << endl;
}

Measured memory_bytes: 67428
def main():
    n = int(input())
    m = [10 ** 5 for _ in range(n + 1)]
    m[0] = 0
    for i in range(1, n + 1):
        j = 0
        while i - 6 ** j >= 0:
            m[i] = min(1 + m[i - 6 ** j], m[i])
            j += 1
        j = 0
        while i - 9 ** j >= 0:
            m[i] = min(1 + m[i - 9 ** j], m[i])
            j += 1

    print(m[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3864
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

string ans = "No";
vector<vector<int>> card(3, vector<int>(3));
vector<vector<bool>> status(3, vector<bool>(3, false));

int main()
{
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> card[i][j];
    }
  }

  int n;
  cin >> n;
  set<int> ns;
  for (int i = 0; i < n; i++)
  {
    int b;
    cin >> b;
    ns.insert(b); 
  }

  for (int i = 0; i < 3; i++)
  {
    bool bingo = true;
    for (int j = 0; j < 3; j++)
    {
      if (ns.count(card[i][j]) < 1) bingo = false;
    }
    if (bingo)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }

  for (int i = 0; i < 3; i++)
  {
    bool bingo = true;
    for (int j = 0; j < 3; j++)
    {
      if (ns.count(card[j][i]) < 1) bingo = false;
    }
    if (bingo)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }

  if (ns.count(card[0][0]) > 0
    && ns.count(card[1][1]) > 0
    && ns.count(card[2][2]) > 0)
  {
    cout << "Yes" << endl;
    return 0;
  }

  if (ns.count(card[0][2]) > 0
    && ns.count(card[1][1]) > 0
    && ns.count(card[2][0]) > 0)
  {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	string S;
	cin >> N >> S;

	vector<vector<int>> memo(26, vector<int>(S.size())), rmemo(26, vector<int>(S.size()));

	for (int i = 0; i < (int)S.size(); i++) {
		memo[S[i] - 'a'][i] = 1;
	}
	for (int i = (int)S.size() - 1; i >= 1; i--) {
		for (int j = 0; j < 26; j++) {
			if(i == (int)S.size() - 1)rmemo[j][i] = memo[j][i];
			rmemo[j][i - 1] = rmemo[j][i] + memo[j][i - 1];
		}
	}
	for (int i = 1; i < (int)S.size(); i++) {
		for (int j = 0; j < 26; j++) {
			memo[j][i] += memo[j][i - 1];
		}
	}		

	int ans = -INF, cnt;
	for (int i = 0; i < (int)S.size() - 1; i++) {
		cnt = 0;
		for (int j = 0; j < 26; j++) {
			if (memo[j][i] != 0 && rmemo[j][i+1] != 0) cnt++;
		}
		ans = max(ans, cnt);
	}

	cout << ans << "\n";

	return 0;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}

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

typedef long long ll;

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

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

int f(int n) {
    int res = 0;
    while (n % 2 == 0) {
        res++;
        n /= 2;
    }
    return res;
}

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

    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 1) {
            cout << 0 << endl;
            return 0;
        }
        A[i] /= 2;
    }

    int t = f(A[0]);
    for (int i = 1; i < N; i++) {
        if (f(A[i]) != t) {
            cout << 0 << endl;
            return 0;
        }
        A[i] >>= t;
    }

    ll l = 1;
    for (int i = 0; i < N; i++) {
        l = lcm(l, A[i]);
        if (l > M) {
            cout << 0 << endl;
            return 0;
        }
    }

    M /= l;
    int res = (M + 1) / 2;
    cout << res << endl;
    return 0;
}

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

using namespace std;

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

  int N;
  cin>>N;
  vector<int> P(N);
  for (auto& p : P) cin>>p;

  vector<int> id(N);
  iota(id.begin(), id.end(), 0);
  sort(id.begin(), id.end(), [&](int l, int r) {
    return P[l] > P[r];
  });

  long ans = 0;
  multiset<int> pset={-1,-1,N,N};
  for (int i = 0; i < N; i++) {
    auto ii = id[i];
    auto l2i = --pset.lower_bound(ii);
    int l2 = *l2i;
    int l1 = *(--l2i);
    auto r1i = pset.upper_bound(ii);
    int r1 = *r1i;
    int r2 = *(++r1i);
    ans += (long)P[ii] * ((l2-l1)*(r1-ii) + (ii-l2)*(r2-r1));
    pset.insert(ii);
  }
  cout << ans << endl;

  return 0;
}


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

const ll INF = 1e18L;

int main() {
  ll n, p;
  cin >> n >> p;
  vector<int> w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  ll s = accumulate(v.begin(), v.end(), 0);
  vector<ll> dp(s + 1, INF);
  dp[0] = 0;
  rep(i, n) for (ll x = s - v[i]; x >= 0; --x) {
    dp[x + v[i]] = min(dp[x + v[i]], dp[x] + w[i]);
  }
  ll ans = 0;
  for(ll i=0; i <= s; ++i) if (dp[i] <= p) { ans = max(ans, i); }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define mod 1000000007

using namespace std;

int main() {
    IOS;
  ll n,k;
  cin>>n;
  string s;
  cin>>s;
  cin>>k;
  for(int y=0;y<s.length();y++)
  {
      if(s[y]!=s[k-1])
        cout<<"*";
      else
        cout<<s[y];
  }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

int main() {
    ll N,M;
    cin >> N >> M;
    ll time = 1;
    ll one = M * 1900 + (N - M) * 100;
    rep(i,M)time *= 2;
    cout << time * one << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int min(int X, int Y) {
    return X < Y ? X : Y;
}

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

    int A, cnt = 0;
    REP(0, i, M) {
        scanf("%d", &A);
        if (A < X) cnt++;
    }

    printf("%d\n", min(cnt, M - cnt));

    return 0;
}


Measured memory_bytes: 128
from sys import stdin, stdout
import math,sys,heapq
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
from os import path
import bisect as bi
def yes():print('YES')
def no():print('NO')
if (path.exists('input.txt')): 
    #------------------Sublime--------------------------------------#
    sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
    def I():return (int(input()))
    def In():return(map(int,input().split()))
else:
    #------------------PYPY FAst I/o--------------------------------#
    def I():return (int(stdin.readline()))
    def In():return(map(int,stdin.readline().split()))

def dict(a):
    d={}
    for x in a:
        if d.get(x,-1)!=-1:
            d[x]+=1
        else:
            d[x]=1
    return d

def find_gt(a, x):
    'Find leftmost value greater than x'
    i = bi.bisect_right(a, x)
    if i != len(a):
        return i
    else:            
        return -1

def main():
    try:
        n=I()
        if n>=30:
            print('Yes')
        else:
            print('No')

    except:
        pass
        
M = 998244353
P = 1000000007
 
if __name__ == '__main__':
    #for _ in range(I()):main()
    for _ in range(1):main()




Measured memory_bytes: 9484
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define EPS 1e-8

using namespace std;

struct Point3D
{
	double x,y,z;

	Point3D(double x,double y,double z) : x(x),y(y),z(z) {}

	Point3D operator+(const Point3D &o)
	{
		return Point3D(x+o.x,y+o.y,z+o.z);
	}

	Point3D operator-(const Point3D &o)
	{
		return Point3D(x-o.x,y-o.y,z-o.z);
	}

	Point3D operator*(const double m)
	{
		return Point3D(x*m,y*m,z*m);
	}

	Point3D operator/(const Point3D &o)
	{
		return Point3D(x/o.x,y/o.y,z/o.z);
	}

	Point3D cross(const Point3D &o)
	{
		return Point3D(y*o.z-z*o.y , z*o.x-x*o.z , x*o.y-y*o.x);
	}

	double dot(const Point3D &o)
	{
		return x*o.x + y*o.y + z*o.z;
	}
};

int main()
{
	double t1,t2,t3;
	
	cin >> t1 >> t2 >> t3;
	Point3D p(t1,t2,t3);

	cin >> t1 >> t2 >> t3;
	Point3D e(t1,t2,t3);

	vector<Point3D> v;
	rep(i,3)
	{
		cin >> t1 >> t2 >> t3;
		v.push_back(Point3D(t1,t2,t3));	
	}

	Point3D d = (v[1]-v[0]).cross(v[2]-v[0]);

	if(d.dot(p-v[0]) * d.dot(e-v[0]) > 0)
	{
		cout << "HIT" << endl;
	}
	else
	{
		Point3D p2 = p + (e-p) * (fabs(d.dot(p-v[0])) / (fabs(d.dot(p-v[0])) + fabs(d.dot(e-v[0]))));

		if((v[1]-v[0]).cross(p2-v[1]).dot((v[2]-v[1]).cross(p2-v[2])) > -EPS && (v[1]-v[0]).cross(p2-v[1]).dot((v[0]-v[2]).cross(p2-v[0])) > -EPS)
		{
			cout << "MISS" << endl;
		}
		else
		{
			cout << "HIT" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1224
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <algorithm>
#define N 401000
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
char s[N];
int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	int sum = 0;
	for (int i = 1; i <= n; ++i) {
		sum += s[i] - '0';
	}
	if (sum % 9)	puts("No");
	else	puts("Yes");
	return 0;
}



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

int find_par(int i,int par[])
{
	if(par[i]==-1)
		return -1;
		
	if(i==par[i])
		return i;
	par[i]=find_par(par[i],par);
	return par[i];
}

vector<pair<int,int> > v,v1;
long long ans=0;

void find_ans(int n,vector<pair<int,int> > &v)
{
	int par[n];
		
	for(int i=0;i<n;i++)
	{
		par[i]=i;
	}
	
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	
	for(int i=0;i<v.size();i++)
	{
		if(v[i].second>=0)
		{
			int p=find_par(v[i].second,par);
		
			if(p!=-1)
			{
				ans+=v[i].first;
				par[p]=p-1;
			}	
		}
	}
}

int main()
{
	int t;
	cin>>t;
	
	while(t--)
	{
		v.clear();
		v1.clear();
		
		ans=0;
		
		int n;
		cin>>n;
				
		int k[n];
		int r[n];
		int l[n];
				
		for(int i=0;i<n;i++)
		{
			cin>>k[i]>>l[i]>>r[i];
			k[i]--;
			
			ans+=min(l[i],r[i]);
			
			if(l[i]>=r[i])
			{
				v.push_back({l[i]-r[i],k[i]});
			}
			else
			{
				v1.push_back({r[i]-l[i],n-k[i]-2});
			}
		}
		
		find_ans(n,v);
		find_ans(n,v1);
		
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 8000
import java.util.*;
 
public class Main {
  public static void main(String[] args ){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int X = sc.nextInt();
    
    if(K*500>=X){
       System.out.println("Yes");
    }
    else{
       System.out.println("No");
    }
  }
}

Measured memory_bytes: 20052
#include<bits/stdc++.h>
using namespace std;
struct var{
	int to,nxt,c;
}edge[201001];
int n,m,x,y,cnt,head[101001],e,c[3],col[101001],t,num;
bool vis[101001];
long long ans;
void add(int u,int v,int c)
{
	cnt++;
	edge[cnt].to=v;
	edge[cnt].nxt=head[u];
	edge[cnt].c=c;
	head[u]=cnt;
}
int should(int o,int f)
{
	if(f==0)return (o+1)%3;
	else return (o-1+3)%3;
}
void dfs(int o)
{
	num++;
	for(int i=head[o];i;i=edge[i].nxt)
	{
		if(!edge[i].c)e++;
		int v=edge[i].to;
		if(col[v]!=-1)
		{
			if(col[v]!=should(col[o],edge[i].c))
			{
				t=-1;
			}
		}else
		{
			col[v]=should(col[o],edge[i].c);
			if(t!=-1&&!c[col[v]])t++;
			c[col[v]]++;
			dfs(v);
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		add(x,y,0);
		add(y,x,1);
	}
	memset(col,-1,sizeof(col));
	for(int i=1;i<=n;i++)
	{
		if(col[i]!=-1)continue;
		c[0]=1,c[1]=c[2]=0;
		col[i]=0;
		vis[i]=1;
		e=0;
		t=1;
		num=0;
		dfs(i);
		if(t==-1)ans+=1ll*num*num;
		else if(t<3)ans+=1ll*e;
		else ans+=1ll*c[0]*c[1]+1ll*c[0]*c[2]+1ll*c[1]*c[2];
	}
	printf("%lld",ans);
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
 
long long gcd(long long a,long long b)
{
	 return (!b)?a:gcd(b,a%b);
}
int main()
{
	long long n,m;
	 map<long long ,long long>q;
	 cin>>n>>m;
	 int flag=0;
	 string s,t;
	 cin>>s;
	 cin>>t;
	 long long l=n*m/gcd(n,m);
	 for(long long i=0;i<n;i++)
	 {
	 	 
	 	 	q[i*l/n+1]=s[i]-'a'+1;
		  
	 	 
	 }
	 
	 for(long long i=0;i<m;i++)
	 {
	 	 
	 	 	if(q[i*l/m+1]==t[i]-'a'+1||q[i*l/m+1]==0)
	 	 	continue;
	 	 	else
	 	 	{
	 	 		flag=1;
	 	 		break;
			  }
		  
	 }
	 if(flag)printf("-1");
	 else printf("%lld",l);
 } 


Measured memory_bytes: 10880
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	d := scanInt()
	n := scanInt()

	if n == 100 {
		n++
	}

	ans := 1
	for i := 0; i < d; i++ {
		ans *= 100
	}
	fmt.Fprintln(wr, ans*n)
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<utility>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define multiCase int T;cin>>T;for(int t=1;t<=T;t++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repp(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define perr(i,a,b) for(int i=a;i>b;i--)
#define pb push_back
#define eb emplace_back
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=0x3f3f3f3f;
const ll LINF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-12;
const double PI=acos(-1.0);
const double ATRconst=PI/180.0;
const ll mod=998244353;
ll max_3(ll a,ll b,ll c){if(a>b&&a>c)return a;if(b>c)return b;return c;}
ll min_3(ll a,ll b,ll c){if(a<b&&a<c)return a;if(b<c)return b;return c;}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll n){ll r=1;while(n){if(n&1)r=(r*a)%mod;n>>=1;a=(a*a)%mod;}return r;}

int a[100050];

void solve()
{
    int n;
    ll ans=1,tmp=1,sum=0;
    cin>>n>>a[0];
    if(a[0])
    {
        if(a[0]!=1)
        {
            cout<<-1<<'\n';
            return;
        }
        rep(i,1,n)
        {
            cin>>a[i];
            if(a[i])
            {
                cout<<-1<<'\n';
                return;
            }
        }
        cout<<1<<'\n';
        return;
    }
    rep(i,1,n)
    {
        cin>>a[i];
        sum+=a[i];
    }
    rep(i,1,n)
    {
        tmp=min(tmp<<1,sum);
        if(a[i]>tmp)
        {
            cout<<-1<<'\n';
            return;
        }
        ans+=tmp;
        tmp-=a[i];
        sum-=a[i];
    }
    cout<<ans<<'\n';
}
int main()
{
    closeSync;
    //multiCase
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3552
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <queue>

using namespace std;

template <typename T> void chkmax (T &x, T y) {x = x > y ? x : y;}
template <typename T> void chkmin (T &x, T y) {x = x > y ? y : x;}

typedef long long ll;

const int INF = 2139062143;

#define DEBUG(x) std::cerr << #x << " = " << x << std::endl

template <typename T> void read (T &x) {
    x = 0; bool f = 1; char ch;
    do {ch = getchar(); if (ch == '-') f = 0;} while (ch > '9' || ch < '0');
    do {x = x * 10 + ch - '0'; ch = getchar();} while (ch >= '0' && ch <= '9');
    x = f ? x : -x;
}

template <typename T> void write (T x) {
    if (x < 0) x = ~x + 1, putchar ('-');
    if (x > 9) write (x / 10);
    putchar (x % 10 + '0');
}

const int N = 1e5 + 7;

ll h, n, s, a[N];

int main () {
	read (h); read (n);
	for (int i = 1; i <= n; i ++ ) read (a[i]), s += a[i];
	sort (a + 1, a + n + 1);
	if (s >= h) puts ("Yes");
	else puts ("No");
	return 0;
}


Measured memory_bytes: 1024
h, w, k = map(int, input().split())
mass = []
black_count = 0
ans = 0
for _ in range(h):
    row = list(input())
    mass.append(row)
    black_count += row.count("#")

goal = black_count - k    

for i in range(2**h):
    row_tmp = str(bin(i)).split("0b")[1]
    row_tmp = '0'*(h - len(row_tmp))+row_tmp
    for j in range(2**w):
        col_tmp = str(bin(j)).split("0b")[1]
        col_tmp = '0'*(w - len(col_tmp))+col_tmp
        
        row_count = 0
        col_count = 0
        for k in range(h):
            row_count += (mass[k] * int(row_tmp[k])).count("#")
        for k in range(h):
            for l in range(w):
                col_count += (mass[k][l] * (int(col_tmp[l]) * (1-int(row_tmp[k])))).count("#")
        if goal == row_count+ col_count:
            ans += 1
print(ans)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define rep(i, c) for (int i = 0; i < (c);i++)
using ll = long long;
using namespace std;
int main(){
  int K;
  int cnt = 0;
  cin >> K;
  queue<ll> a;
  for (int i = 1; i <=9 ;i++){
    a.push(i);
  }
  while(1){
   long long  int tmp = a.front();
    a.pop();
    cnt++;
    //cout << tmp << endl;
    if(cnt==K){
      cout << tmp << endl;
      return 0;
    }
    int ans = tmp % 10;
    if(ans==0){
      a.push(tmp * 10);
      a.push(tmp * 10 + 1);
    }else if(ans==9){
      a.push(tmp * 10 + ans - 1);
      a.push(tmp * 10 + ans);
    }else{
    for (int i = ans-1; i <= ans+1; i++)
    {
      a.push(tmp*10 + i);
    }
    }
  }
}

Measured memory_bytes: 1792
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define NL << endl

using namespace std;
using ll = long long;
using ull = unsigned long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto& e : a) cin >> e;
	vector<int> b(a);

	sort(a.begin(), a.end(), greater<int>());

	ll sum = 0;
	ll sum2 = 0;
	if (n == 2) {
		sum = a[0] - a[1];
	} else if (n & 1) {
		for (int i = 0; i < n; i++) {
			if (i < (n + 1) / 2) {
				sum += a[i] * 2;
			} else {
				sum -= a[i] * 2;
			}
		}
		sum -= a[(n + 1) / 2 - 2];
		sum -= a[(n + 1) / 2 - 1];
		for (int i = 0; i < n; i++) {
			if (i < n / 2) {
				sum2 += a[i] * 2;
			} else {
				sum2 -= a[i] * 2;
			}
		}

		sum2 += a[n / 2] + a[n / 2 + 1];
	} else {
		for (int i = 0; i < n; i++) {
			if (i < n / 2) {
				sum += a[i] * 2;
			} else {
				sum -= a[i] * 2;
			}
		}
		sum -= a[n / 2 - 1];
		sum += a[n / 2];

	}

	cout << max(sum, sum2) NL;

	return 0;

}



Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i, a, n) for(LL i = (a), i##_max = (n); i < i##_max; ++i)
#define REM(i, a, n) for(LL i = (LL)(n) - 1, i##min = (a); i >= i##min; --i)
#define ALL(arr) (arr).begin(), (arr).end()
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(NULL); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
template <class T>
T Next() { T buf; cin >> buf; return buf; }

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "BinaryMatrix.h"
#include "BIT.h"
#include "Factorization.h"
#include "FlowSolver.h"
#include "Graph.h"
#include "LazySegmentTree.h"
#include "Math.h"
#include "Matrix.h"
#include "MinMax.h"
#include "Position.h"
#include "Range.h"
#include "Rational.h"
#include "SegmentTree.h"
#include "SegmentTree2D.h"
#include "SuffixArray.h"
#include "Tree.h"
#include "UnionFind.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
// template <class T>
// auto Is(const T& value) { return [value](const auto& comparand) -> bool { return comparand == value; }; }
#endif

int main() {
	int N, K;
	cin >> N >> K;
	cout << (N - K + 1) << endl;
	return 0;
}


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

blist = []
flist = []
rlist = []
vlist = []

for _ in range(n):
    b, f, r, v = map(int, input().split())
    blist.append(b)
    flist.append(f)
    rlist.append(r)
    vlist.append(v)

arr4 = [[[0 for i3 in range(10)] for i2 in range(3)] for i1 in range(4)]

for b, f, r, v in zip(blist, flist, rlist, vlist):
    arr4[b-1][f-1][r-1] += v

for b in range(3):
    for f in range(3):
        for r in range(10):
            print(" " + str(arr4[b][f][r]), end="")
        print()
    print("####################")

for f in range(3):
    for r in range(10):
        print(" " + str(arr4[3][f][r]), end="")
    print()



Measured memory_bytes: 5628
#include <stdio.h>
#include <string.h>
 
int main() {
  char a[200], b[100], c[200];
 
  scanf("%s", a);
  scanf("%s", b);
  strcpy(c,a);
  strcat(c,a);
 
  if (strstr(c,b)) {
      printf("Yes\n");
  } else {
      printf("No\n");
  }
 
  return 0;
}

Measured memory_bytes: 2736
input_line = list(map(int,input().split(' ')))

if(2*input_line[0]>input_line[1]):
    print('No')
elif(4*input_line[0]<input_line[1]):
    print('No')
elif(input_line[1]%2!=0):
    print('No')
else:
    leg = input_line[0]*2
    for i in range(input_line[0]+1):
        if(leg+i*2):
            print('Yes')
            break
    else:
        print('No')


Measured memory_bytes: 9192
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int e[101][101];
	int R, C, r, c;
	int s, total;

	scanf("%d%d", &R, &C);
	for (r = 1; r <= R; r++) {
		for (c= 1; c <= C; c++) scanf("%d", &e[r][c]);
	}
	
	for (r = 1; r <= R; r++) {
		s = 0;
		for (c = 1; c <= C; c++) s += e[r][c];
		e[r][0] = s;
	}
	total = 0;
	for (c = 1; c <= C; c++) {
		s = 0;
		for (r = 1; r <= R; r++) s += e[r][c];
		e[0][c] = s;
		total += s;
	}
	for (r = 1; r <= R; r++) {
		for (c = 1; c <= C; c++) printf("%d ", e[r][c]);
		printf("%d\n", e[r][0]);
	}
	for (c = 1; c <= C; c++) printf("%d ", e[0][c]);
	printf("%d\n", total);
	return 0;
}



Measured memory_bytes: 2048
#include<iostream>
using namespace std;
 
int main()
{
 char c;
 int N,M,x,y,i,j,field[21][21],d;
 while(cin>>N,N){
  for(i=0;i<21;i++)for(j=0;j<21;j++)field[i][j]=0;
  while(N-->0){cin>>x>>y;field[y][x]=1;}
  cin>>M;
  x=y=10;
  while(M-->0){
   cin>>c>>d;
   while(d-->0){
    if(c=='N')y++;
    if(c=='S')y--;
    if(c=='E')x++;
    if(c=='W')x--;
    field[y][x]=0;
   }
  }
  d=0;
  for(i=0;i<21;i++)for(j=0;j<21;j++)d+=field[i][j];
  if(d)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
 }
}

Measured memory_bytes: 0
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    int al = 0;
    int bb = 0;
    for(int i=n-1;i>=0;i-=2){
        al+=a[i];
    }
    for(int i=n-2;i>=0;i-=2){
        bb+=a[i];
    }
    cout << al-bb << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n, k;

	cin >> n >> k;

	int a[n];
	int ans = 0;

	int i;

	rep(i, n) cin >> a[i];

	sort(a, a + n, std::greater<int>());

	rep(i, k) ans += a[i];

	Out(ans);
	
	return 0;
}


Measured memory_bytes: 256