akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) (a).begin(),(a).end()


int main(void){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    int l = 1, r = n-2;
    ll lv=a[0], rv=a[n-1];
    ll sum = rv - lv;
    while(l<=r){
        ll ds[4] = {abs(lv - a[l]), abs(lv - a[r]), abs(rv - a[l]), abs(rv - a[r])};
        int i = 0;
        ll dmax = 0;
        rep(j,4){
            if(dmax < ds[j]){
                dmax = ds[j];
                i = j;
            }
        }
        sum += dmax;
        if(i==0){
            lv = a[l];
            l++;
        }
        if(i==1){
            lv = a[r];
            r--;
        }
        if(i==2){
            rv = a[l];
            l++;
        }
        if(i==3){
            rv = a[r];
            r--;
        }
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main() {
	string str;
	cin >> str;
	if (str == "Sunny")
		cout << "Cloudy" << endl;
	else if (str == "Cloudy")
		cout << "Rainy" << endl;
	else
		cout << "Sunny" << endl;
	return 0;
}


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

int main() {
  
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    
    if( e-a<=k ){ cout << "Yay!" << endl; }
    else{ cout << ":(" << endl; }
  

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=-mod;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m,long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m,long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x,long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//nCr
long long C(long long n, long long r);
//nCr (mod)
long long modC(long long n, long long r) {
    vector<long long> f(n+1),inv(n+1),invf(n+1);
    f[0]=f[1]=1;
    invf[0]=invf[1]=1;
    inv[1]=1;
    for (long long i=2;i<n+1;i++) {
        f[i]=(i*f[i-1])%mod;
        inv[i]=mod-((mod/i)*inv[mod%i])%mod;
        invf[i]=(inv[i]*invf[i-1])%mod;
    }
    long long cmb=f[n]*(invf[r]*invf[n-r]%mod)%mod;
    if (n>=r) return cmb;
    else return 0;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  string s;cin>>s;
  ll N=s.size();
  
  //スタンバイしている'A'
  ll have_a=0;
  //Bが前に来て、'BC'の準備ができているか
  bool have_b=false;
  ll res=0;
  
  rep(i,N){
    if(s[i]=='A'){
      if(have_b){
        have_a=0;
      }
      have_a++;
      have_b=false;
    }
    else if(s[i]=='B'){
      if(have_b){
        have_a=0;
      }
      have_b=true;
    }
    else if(s[i]=='C'){
      if(have_b){
        res+=have_a;
      }
      else{
        have_a=0;
      }
      have_b=false;
    }
  }
  
  cout<<res;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
long long int x,a,b;
	cin >> x >> a >> b;
	if(x >= (b -= a)){
		if(b <= 0)
			cout << "delicious" << endl;
		else
			cout << "safe" << endl;
	}else
		cout << "dangerous" << endl;
}

Measured memory_bytes: 256
import heapq

N, K = map(int,input().split())
V = list(map(int,input().split()))

num = min(N, K)

lst = []

for i in range(1,num+1):
    for j in range(i+1):
        lst.append([j,i-j,K-i])

MAX = -100000000

for A, B, p in lst:
    tmp = sum(V[:A]) + sum(V[N-B:])
    D = V[:A] + V[N-B:]
    heapq.heapify(D)
    for _ in range(p):
        if not D:
            break
        k = heapq.heappop(D)
        if k >= 0:
            break
        else:
            tmp -= k
    if tmp > MAX:
        MAX = tmp

print(MAX)

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

int main(void)
{
    int n; cin >> n;
    vector<int> sub(n, 0);
    int a;
    for (int i = 0; i < n - 1; i++)
    {
        cin >> a;
        sub[a-1]++;
    }
    for (int p:sub) cout << p << endl;
}

Measured memory_bytes: 3988
#include <stdio.h>
int main(void){
	char s[20];

	for(int i=0; i<19; i++){
		scanf("%c", &s[i]);
	}

	s[5]=' ';
	s[13]=' ';

	for(int i=0; i<19; i++){
		printf("%c",s[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
	public static void main(String[] args){
    Scanner scn = new Scanner(System.in);
      
    int A = scn.nextInt();
    int B = scn.nextInt(); 
    int C = 0;
      
    if(B%A==0){
    C=A+B;
    }else{
    C=B-A;
    }
      System.out.print(C);
    }
}
    

Measured memory_bytes: 23124
#include <bits/stdc++.h>
 
using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

const int N = 100000;

int n, m;
ll dis[N + 5];
bool vis[N + 5];
vector<pii> G[N + 5];

bool flag = true;

void dfs(int u, ll d) {

    if(vis[u]) {
        if(dis[u] != d) flag = false;
        return;
    }

    vis[u] = 1;
    dis[u] = d;

    for(int i = 0; i < (int) G[u].size(); ++i) {
        dfs(G[u][i].fst, d + G[u][i].snd);
    }
}

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif 

    read(n), read(m);
    for(int i = 1; i <= m; ++i) {
        static int l, r, d;
        read(l), read(r), read(d);

        G[r].pb(mp(l, d));
        G[l].pb(mp(r, -d));
    }

    for(int i = 1; i <= n; ++i) if(!vis[i]) {
        dfs(i, 0);
    }
    puts(flag ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int N, max = -1, index = 0;
  cin >> N;

  for(int i=1; i<=N; ++i) {
    int keep = i;
    int res = 0;
    while(true) {
      if(keep==0) break;
      if(keep%2!=0) break;
      ++res;
      keep = keep/2;
    }
    if(max < res) {
      index = i;
      max = res;
    }
  }

  cout << index << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long n = Long.parseLong(sc.next());
		Long a = Long.parseLong(sc.next());
		Long b = Long.parseLong(sc.next());
		
		if((a - b) % 2 == 0 ) {
			System.out.println(Math.abs(a -b)/2);
		}else {
			
			//壁に集まる
			Long temp1 = Math.max(a -1, b - 1);
			Long temp2 = Math.max(n - a , n - b);
			Long ans = Math.min(temp1,temp2);
			
			//左壁で調整
			Long ans2 = ((b - a - 1) /2 ) +  a;
			if(ans2 >= 0) {
				ans = Math.min(ans, ans2);
			}
			
			//右壁で調整
			Long ans3 =((n -(a + n- b + 1))/2) + (n - b + 1)  ;
			if(ans3 >= 0) {
				ans = Math.min(ans, ans3);
			}
			
			System.out.println(ans);
			
		}
		

	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//const ll mod=1000000007;

int main() {
    ll x;
    cin >> x;
    ll ans = 0;
    if(x <= 6) {
        cout << 1 << endl;
        return 0;
    }
    ans += x / 11;
    ans *= 2;
    x %= 11;
    if(x == 0) cout << ans << endl;
    else if(x <= 6) cout << ans + 1 << endl;
    else cout << ans + 2 << endl;
}

Measured memory_bytes: 256
cards = []
["S", "H", "C", "D"].each do |i|
  ("1".."13").each do |j|
    cards.push [i, j]
  end
end

n = gets.to_i
taro_cards = []
n.times do
  taro_cards.push gets.chomp.split(" ")
end

difference = cards - taro_cards
difference.each do |i|
  puts i.join(" ")
end

Measured memory_bytes: 8720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    ll n,h,w;
    cin>>n>>h>>w;
    ll cnt=0;
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        if(a>=h&&b>=w)cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
LL A[2], B[2];

void INF() {
     puts("infinity");
     exit(0);
}

void NO() {
     puts("0");
     exit(0);
}

int main() {
    int T1, T2;
    scanf("%d %d", &T1, &T2);
    scanf("%lld %lld", &A[0], &A[1]);
    scanf("%lld %lld", &B[0], &B[1]);
    if (A[0] < B[0]) {
       swap(A[0], B[0]);
       swap(A[1], B[1]);
    }
    if (A[0] == B[0]) INF();
    // A0 > B0
    LL tmp = (A[0] - B[0]) * T1 + (A[1] - B[1]) * T2;
    if (!tmp) INF();
    if (tmp > 0) NO();
    tmp *= -1;
    LL cnt = (A[0] - B[0]) * T1;
    LL ans = 0;
    if (cnt % tmp) ans++;
    printf("%lld\n", ans + (cnt / tmp) * 2);


    return 0;
}


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

int main()
{
  int n,k,i,sum;
  vector<int>a;
  double maxi;
  
  cin>>n>>k;
  
  a.resize(n);
  for(i=0;i<n;++i)
  cin>>a[i];
  
  maxi=-1.0;
  for(i=0;i<k;++i)
  sum+=a[i];

  maxi=max(maxi,(sum+k)/2.0);
  for(i=k;i<n;++i)
  {
    sum-=a[i-k];
    sum+=a[i];
    maxi=max(maxi,(sum+k)/2.0);    
  } 
  
  cout<<fixed<<setprecision(12)<<maxi;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	string s;
	cin>>s;
	ll arr[26];
	memset(arr,0,sizeof(arr));
	for(ll i=0;i<s.length();i++)
	{
		arr[int(s[i]-'a')]+=1;
	}
	int flag=0;
	for(int i=0;i<26;i++)
	{
		if(arr[i]%2!=0)
		{
			flag=1;
			break;
		}
	}
	if(flag==1)
	cout<<"No"<<endl;
	else
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>

int main() {
	long long  r, d, x;

	std::cin >> r >> d >> x;

	for (size_t i = 0; i < 10; i++)
	{
		x = r * x - d;

		std::cout << x << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);

int main(){
    ll n; cin >> n;
    cout << n*(n+1)/2<<endl;
}


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

class hogehoge
{
   static void Main(string[] args)
   {
      string s = Console.ReadLine();
      string t = Console.ReadLine();
      s = String.Concat(s.OrderBy(c => c));
      t = String.Concat(t.OrderByDescending(c => c));

      Console.WriteLine(isSortedAlphabetically(s,t) ? "Yes" : "No");
   }

   static bool isSortedAlphabetically(string s, string t)
   {
      if (s[0] < t[0])
      {
         return true;
      }
      else if (s[0] == t[0])
      {
         if (s.Length == 1 && t.Length == 2) return true;
         if (s.Length == 2 && t.Length == 1) return false;
         if (s.Length == 2 && t.Length == 1) return false;
         if (s.Length == 1 && t.Length == 1) return false;
         return isSortedAlphabetically(s.Substring(1), t.Substring(1));
      }
      else
      {
         return false;
      }
   }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);




using namespace std;

int main()
{
    fast;
    string s; cin >> s;
    int n = s.size();
    vector<string> a;
    int ind = 0;
    string now = "";
    FOR(i, n, 0)
    {
        now += s[i];
        if(i == 0)
        {
           a.pb(now);
            now = "";
            ind++;
        }
        else if(a[ind - 1] == now)continue;
        else
        {
            a.pb(now);
            now = "";
            ind++;
        }
    }
    cout << a.size();
    return 0;
}


Measured memory_bytes: 11016
#include <iostream>
using namespace std;
int main() {
	int w, h, x, y;
	cin >> w >> h >> x >> y;

	cout << (float)((float)w*(float)h / 2.0) << " ";
	if (x * 2 == w&&y * 2 == h) cout << 1;
	else cout << 0;
  
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int n;
  cin >> n;
  string str;
  cin >> str;
  ll r = 0, g = 0, b = 0;
  for (char c : str){
    if (c == 'R'){
      r++;
    } else if (c == 'G'){
      g++;
    } else {
      b++;
    }
  }
  ll total = r * b * g;
  for (int j = 0; j < n; j++){
    for (int d = 1; j - d >= 0 && j + d < n; d++){
      set<char>st;
      st.insert(str[j]);
      st.insert(str[j - d]);
      st.insert(str[j + d]);
      if (st.size() == 3){
        total--;
      }
    }
  }
  cout << total << "\n";
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const ll MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}


int main(){
  int n;
  cin >> n;
  cout<< (1000-n%1000) % 1000 <<endl;
}


Measured memory_bytes: 3612
n = int(input())
l = [[] for _ in range(n)]
ans = 0

for i in range(n):
    a = int(input())
    for j in range(a):
        xy = input().split()
        l[i].append(list(map(int, xy)))

for i in range(2**n):
    judge = True
    for j in range(n):
        if judge == False:
            break
        if i & (1 << j): #証言者が正直者設定なら進む。
            for x, y in l[j]:
                if y == 0 and i & 1 << (x - 1): #証言:不親切 設定:親切
                    judge = False
                if y == 1 and i & 1 << (x - 1) == 0: #証言:正直、設定:不親切
                    judge = False
    if judge == True:
        cnt = bin(i).count("1")
        ans = max(ans, cnt)

print(ans)

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

int main() {
	int n;
	int t[110000], x[110000], y[110000];
	cin >> n;
	t[0] = x[0] = y[0] = 0;
	for (int i = 0; i < n; i++) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];

	bool can = true;
	for (int i = 0; i < n; i++) {
		int dt = t[i + 1] - t[i];
		int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		if (dt < dist) can = false;
		if (dist % 2 != dt % 2) can = false;
	}
	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main(void)
{
    int dice1[7], dice2[7], i, j, k;
    char order[7][3] = {"","","N","W","E","S","NN"};
    
    for(i=1; i<=6; i++){
        scanf("%d", &dice1[i]);
    }    
    for(i=1; i<=6; i++){
        scanf("%d", &dice2[i]);
    }
    
    //上面を見つける
    for(j=1; j<=6; j++){
        if(dice2[j]==dice1[1]){
            break;
        }
    }
    if(j==6 && dice2[6]!=dice1[1]) {
        printf("No\n");
        return 0;
    }
    
    //回転させて上面を合わせる
    for(k=0; order[j][k]!='\0'; k++){
        
        dice2[0]=dice2[1];
        switch(order[j][k]){
          case 'E' :  dice2[1]=dice2[4];
            dice2[4]=dice2[6];
            dice2[6]=dice2[3];
            dice2[3]=dice2[0];
            break;
          case 'N' :  dice2[1]=dice2[2];
            dice2[2]=dice2[6];
            dice2[6]=dice2[5];
            dice2[5]=dice2[0];
            break;
          case 'S' :  dice2[1]=dice2[5];
            dice2[5]=dice2[6];
            dice2[6]=dice2[2];
            dice2[2]=dice2[0];
            break;
          case 'W' :  dice2[1]=dice2[3];
            dice2[3]=dice2[6];
            dice2[6]=dice2[4];
            dice2[4]=dice2[0];
            break;
        }
    }
    
    for(i=0; i<4; i++){
        if(dice1[2]==dice2[2] && dice1[3]==dice2[3] && dice1[4]==dice2[4] ){
            printf("Yes\n");
            return 0;
        }
        dice2[0]=dice2[2];
        dice2[2]=dice2[3];
        dice2[3]=dice2[5];
        dice2[5]=dice2[4];
        dice2[4]=dice2[0];
    }
    
    printf("No\n");
    
    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define maxn 30
#define u32d unsigned int
#define LL   long long
#define INF  0x7FFFFFFF
using namespace std;

int nums[100005]; 
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> nums[i];
	}
	sort(nums, nums + n);
	cout << nums[n / 2] - nums[n / 2 - 1] << endl; 
	return 0;
} 

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

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

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

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

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

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

long long POW(long long a, long long n) {
	long long x = 1LL;
	for (; n > 0; n >>= 1, a *= a)
		x *= ((n & 1) == 1) ? a : 1;
	return x;
}

int main()
{
	int N, P;
	cin >> N  >> P;
	vi A(N);
	cin >> A;

	int f = 0;
	for (auto a : A) if (a % 2 == 1) f++;

	if (f == 0)
		if (P == 1)
			cout << 0 << endl;
		else
			cout << POW(2, N) << endl;
	else
		cout << POW(2, N - 1) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if((a+b)%3==0||a%3==0||b%3==0)
	cout<<"Possible";
	else
	cout<<"Impossible";
	return 0;
}

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

int N, K, A[200005];

bool possible(int maxLen)
{
	long long int cutsLeft = K;
	for(int i = 1; i <= N; i++)
	{
		if(A[i] % maxLen == 0)
			cutsLeft -= A[i] / maxLen;
			
		else
		{
			cutsLeft -= A[i] / maxLen;
			cutsLeft--;
		}
		
		cutsLeft++;
	}
	
	//printf("maxLen = %d, cutsLeft = %d\n", maxLen, cutsLeft);
	return (cutsLeft >= 0ll);
}

int binarySearch()
{
	int maxA = A[1];
	for(int i = 1; i <= N; i++)
		maxA = max(maxA, A[i]);
	
	int L = 1, R = maxA;
	int possAns = R;
	while(L <= R)
	{
		int M = L + (R - L) / 2;
		//printf("M = %d\n", M);
		if(possible(M))
		{
			R = M - 1;
			possAns = M;
		}
		
		else
			L = M + 1;
	}
	
	return possAns;
}

int main()
{
	scanf("%d%d", &N, &K);
	for(int i = 1; i <= N; i++)
		scanf("%d", &A[i]);
		
	printf("%d", binarySearch());
}


Measured memory_bytes: 4592
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <unordered_set>
using namespace std;

int p = 1e9+7;

long mod_pow(long a, long n){
    long bin_n[40];
    long a_pow[40];
    long bin = 1;
    long m = n;
    for(int i = 0; i < 40; i++){
        bin_n[i] = m%2;
        m = m/2;
    }
    a_pow[0] = a;
    for(int i = 1; i < 40; i++){
        a_pow[i] = a_pow[i-1]*a_pow[i-1]%p;
    }
    for(int i = 0; i < 40; i++){
        if(bin_n[i] == 1){
            bin = bin*a_pow[i]%p;
        }
    }
    return bin;
}

int main(void){
    long N, a, b;
    cin >> N >> a >> b;
    long fact_N_a = 1;
    for(int i = 0; i < a; i++){
        fact_N_a = fact_N_a*(N-i)%p;
    }
    long fact_N_b = 1;
    for(int i = 0; i < b; i++){
        fact_N_b = fact_N_b*(N-i)%p;
    }
    long fact_a = 1;
    for(int i = 1; i <= a; i++){
        fact_a = fact_a*i%p;
    }
    long fact_b = 1;
    for(int i = 1; i <= b; i++){
        fact_b = fact_b*i%p;
    }
    long comb_N_a = fact_N_a*mod_pow(fact_a, p-2)%p;
    long comb_N_b = fact_N_b*mod_pow(fact_b, p-2)%p;
    long ans = (mod_pow(2, N)-comb_N_a-comb_N_b-1)%p;
    ans = (ans+p)%p;
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;
typedef unsigned int i64;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back

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

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


template <typename T>
void printV(vector<T> A) {
  if (A.empty()) cerr << "EMTPY\n";
  else { 
    cerr << "[";
    for (int i = 0; i < A.size() -1 ; ++i) {
      cerr << A[i] << ", ";
    }
    if (A.size()) cerr << A.back() << "]\n";
  }
}


template <typename T>
void printVV(vector<vector<T>> A) {
  cerr << "[";
  for (auto v : A) {
    printV<T>(v);
  }
  cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k; string s; cin >> k >> s;
  if (s.size() <= k) {
    cout << s << endl;
  }
  else {
    cout << s.substr(0,k) << "..." << endl;
  }
  return 0;
}



Measured memory_bytes: 3656
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<queue>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int MaxN = 1e5;

int a,b;

int main(){
	cin >> a >> b;
	if(a%2 == 0 || b%2 == 0)cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
using namespace std;

int main(){
  ll x;
  cin>>x;
  ll ans1,ans2;
  for(ll a=-150;a<=150;a++){
    for(ll b=-150;b<a;b++){
      if(a*a*a*a*a-b*b*b*b*b==x){
        ans1=a;
        ans2=b;
      }
    }
  }
  cout<<ans1<<" "<<ans2;
}

Measured memory_bytes: 3596
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

int main() {
    long long s;
    cin >> s;

    long long x1, x2, y1, y2;

    if (s <= 1000000000) {
        x1 = s;
        y1 = 0;
        x2 = 0;
        y2 = 1;
        cout << 0 << endl;
        cout << 0 << endl;
        cout << x1 << endl;
        cout << y2 << endl;
        cout << x2 << endl;
        cout << y2 << endl;
        return 0;
    } else {
        x1 = 100000;
        y2 = 100000;
        x2 = 0;
        while (x1 * x2 <= s) {
            ++x1;
            if (x1 * y2 >= s) {
                x2 = x1 * y2 - s;
                cout << 0 << endl;
                cout << 0 << endl;
                cout << x1 << endl;
                cout << 1 << endl;
                cout << x2 << endl;
                cout << y2 << endl;
                break;
            }
            ++y2;
            if (x1 * y2 >= s) {
                x2 = x1 * y2 - s;
                cout << 0 << endl;
                cout << 0 << endl;
                cout << x1 << endl;
                cout << 1 << endl;
                cout << x2 << endl;
                cout << y2 << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

int paper[10][10]={0};

void drop(int x,int y){
    
    if(0<=x && x<10 && 0<=y && y<10){
        paper[x][y]++;
    }
    
}

int main(){
    int x,y,s,ans_zero=0,ans_max=0;
    
    while(EOF!=scanf("%d,%d,%d",&x,&y,&s)){
        
        switch (s) {
            case 1: //small
                drop(x-1,y);
                drop(x,y-1);
                drop(x+1,y);
                drop(x,y+1);
                drop(x,y);
                break;
                
            case 3:
                drop(x+2,y);
                drop(x,y+2);
                drop(x-2,y);
                drop(x,y-2);
                
            case 2: //medium
                for(int i=x-1;i<=x+1;i++){
                    for(int j=y-1;j<=y+1;j++){
                        drop(i,j);
                    }
                }
                break;
        }
    }
    
    
    
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            if(paper[i][j]==0)
                ans_zero++;
            ans_max=max(ans_max,paper[i][j]);
        }
    }
    
    printf("%d\n%d\n",ans_zero,ans_max);
    
    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  if (n % 2 == 1) {
    for (int i = n - 1; i >= 0; i -= 2)
      cout << a[i] << " ";
    for (int i = 1; i < n; i += 2)
      cout << a[i] << " ";
  } else {
    for (int i = n - 1; i >= 0; i -= 2)
      cout << a[i] << " ";
    for (int i = 0; i < n; i += 2)
      cout << a[i] << " ";
  }
  return 0;
}

Measured memory_bytes: 4368
n=int(input())
f=[list(map(int,input().split()))for i in range(n)]
p=[list(map(int,input().split()))for i in range(n)]
cost=-float("inf")
for i in range(1,1<<10):
    ans=0
    for j in range(n):
        cnt=0#自分が作ったbitと配列fで被っているところの数を数える
        for k in range(10):
            if i&(1<<k) and f[j][k]==1:
                cnt+=1
        ans+=p[j][cnt]
    cost=max(ans,cost)
print(cost)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>

using namespace std;
using Map = unordered_map<string, long>;

size_t n;

void dfs(string src, Map &m, size_t i=0, string s="", string t="") {
    if (i == n){
        m[s + ' ' + t]++;
    } else {
        dfs(src, m, i+1, s+src[i], t);
        dfs(src, m, i+1, s, t+src[i]);
    }
}

int main() {
    string src;
    Map m1, m2;
    cin >> n >> src;
    string left  = src.substr(0, n),
           right = src.substr(n);
    reverse(right.begin(), right.end());
    dfs(left, m1);
    dfs(right, m2);
    long cnt = 0;
    for (auto mp:m1) 
        cnt += mp.second * m2[mp.first];
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 87412
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long int
#define mkp make_pair
#define maxN 1005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
}
void printMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printVec(vector<int>v)
{
for(int i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void printVec2(vector<int>v[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
 set<pair<int,int>> primeset;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primeset.insert(mkp(p,1));
}
pi g1[1000006],g2[1000006];
int arr[maxN][maxN];

int32_t main(){
    fastio;
int a;in a;int b;in b;
SieveOfEratosthenes(5);
if(b==1)
    out 0<<endl;
else{
    int temp=a;
    SieveOfEratosthenes(5);
    int ans=1;
    SieveOfEratosthenes(5);
    while(a<b){
        ans++;SieveOfEratosthenes(5);
        a=temp-1+a;
    }SieveOfEratosthenes(5);
    out ans;
}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int i = 0; i < n; i++) cin >> q[i];

    vector<int> vec(n);
    for (int i = 0; i < n; i++) vec[i] = i+1;
    int a = 0, b = 0, cnt = 1;
    do {
        if (vec == p) a = cnt;
        if (vec == q) b = cnt;
        cnt++;
    } while (next_permutation(vec.begin(), vec.end()));

    cout << abs(a-b) << endl;
}


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

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

    string s;
    cin >> s;
    int top = 0, bot = 200000;
    rep(i, s.size()){
        if (s[i] == 'A'){
            top = i;
            break;
        }
    }
    drep(i, s.size()){
        if (s[i] == 'Z'){
            bot = i;
            break;
        }
    }
    cout << bot - top + 1 << endl;

    return 0;
}

Measured memory_bytes: 720
import java.io.*;
import java.util.*;


public class Main {
    static long mod = 1000000000+7;
    static int n,a,b,k;
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //String[] buf = reader.readLine().split(" ");
        n = sc.nextInt();
        long ans = 0,head =0, tail = 0, dou = 0;
        for(int i=0;i<n;i++){
            char[] s = sc.next().toCharArray();
            int len = s.length;
            for(int j=0;j<len-1;j++){
                if(s[j]=='A'&&s[j+1]=='B') ans++;
            }
            if(s[0]=='B'&&s[len-1]=='A') dou++;
            else if(s[0]=='B') head++;
            else if(s[len-1]=='A') tail++;
        }
        ans += help(head,tail,dou);
        System.out.println(ans);
    }
    static long help(long head, long tail, long dou){
        if(tail==0&&dou==0) return 0;
        long ans = 0;
        if(tail==0){
            // then dou!=0;
            dou--;
            tail++;
        }
        //if(dou==0) return Math.min(tail,head);
        ans += dou;
        ans += Math.min(tail,head);
        return ans;
    }
}



Measured memory_bytes: 31940
#include <iostream>
using namespace std;
int main(){
	int i,j,n,p[246920]={0};
	for(i=2;i<123457;i++) if(!p[i]) for(j=i;(j+=i)<246914;p[j]=1);
	for(i=2;i<246914;i++) p[i]=p[i-1]+!p[i];
	while(cin>>n,n) cout<<p[n+n]-p[n]<<endl;
}

Measured memory_bytes: 0
from sys import stdin
import numpy as np
n, k, q = map(int, stdin.readline().rstrip().split())
ary = [int(stdin.readline().rstrip()) for _ in range(q)]
point = np.array([0] * n)

for i in ary:
    point[i-1] += 1

point = point + (k - q)

for i in point:
    if i > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 18628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define zapp ios::sync_with_stdio(false);cin.tie(0)
const int MAXN = 1e5 + 5;

int main()
{
	zapp;
	ll n, k;
	cin >> n >> k;
	ll a[n], i;
	for (i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	ll sum = 0;
	for (i = 0; i < k; i++)
		sum += a[i];

	cout << sum;

	return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    string s, t;
    cin >> s >> t;
    s += t[t.length()-1];
    if (s == t) {
        cout << "Yes" <<endl;
    } else {
        cout << "No" << endl;
    }
}


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

int main(){
    char x, y;
    cin >> x >> y;

    int u, v;
    u = x - 'A';
    v = y - 'A';

    if(u < v){
        cout << '<' << endl;
    }else if(u == v){
        cout << '=' << endl;
    }else{
        cout << '>' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>

using namespace std;
const int MOD = 1e9 + 7;

int N;

long long pow(long long x, int n) {
    long long res = 1;
    while (0 < n) {
        if(n % 2 != 0)
            res = res * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return res;
}

int main() {
    cin >> N;
    int num;
    map<int, int> order;
    for (int i = 0; i < N; i++){
        cin >> num;
        order[num]++;
    }

    for(auto index : order) {
        if(index.second != 2 || index.first == 0) {
            if( N % 2 != 0 && index.first == 0 && index.second == 1)
                continue;
            cout << 0 << endl;
            return 0;
        }
    }

    cout << pow(2, N / 2) << endl;
    return 0;
}

Measured memory_bytes: 6392
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> dp(3);
	for(int i=0;i<n;i++)
	{
		vector<int> new_dp(3),rd(3);
		for(int &r: rd)
			scanf("%d",&r);
		new_dp[0] = rd[0] + max(dp[1],dp[2]);
		new_dp[1] = rd[1] + max(dp[0],dp[2]);
		new_dp[2] = rd[2] + max(dp[0],dp[1]);
		dp = new_dp;
	}
	cout<<max(dp[0],max(dp[1],dp[2]))<<'\n';
}

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

using namespace std;

bool check(int x) {
    string s = to_string(x);
    int len = s.size();
    for(int i=0; i<len/2; i++) {
        if(s[i] != s[len-1-i]) return false;
    }
    return true;
}

int main() {
    int a, b; cin >> a >> b;
    
    int cnt = 0;
    for(; a <= b; a++) {
        cnt += (int)check(a);
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,pd[2001],ans;
string s;
int main()
{
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		for(int j=120;j>=0;j--)
		if(pd[j]==1)
		pd[j*11+s[i]-'0'+1]=1;
		pd[s[i]-'0'+1]=1;
	}
	for(int i=121;i<=1331;i++)
	if(pd[i]==1)
	ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
bool compare_by_b(pair<string, int> a, pair<string, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}
signed main(){
  int x=0,y=0,z=0,w=0,n=0;
std::cin >> x;
string s;
std::map<string,int> map;
rep(i,x){
  std::cin >> s;
  map[s]++;
  if(map[s]>y)y=map[s];
}
for(auto& x:map){
  if(x.second==y)std::cout << x.first << '\n';
}
}


Measured memory_bytes: 25216
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f3f;
const int maxn = 1e5+500;
ll T,n,m;
int main() {
    string s1,s2;
    int cnt = 0;
    cin>>s1>>s2;
    for(int i=0;i<s1.length();i++)
    	if(s1[i]==s2[i])
    		cnt++;
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k,ans = 0,z;cin >> n >> k;
  ans += n;
  ll x = max(k,n-k),y = min(k,n-k);
  while(y){
    ans += (x/y)*2*y-(x%y==0 ? y:0);
    z = x%y;
    x = y;y = z;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3636
/*Bismllahir Rahmanir Rahim*/
#include<bits/stdc++.h>
#include<string.h>
#include<stdio.h>
using namespace std;
int main()
{
    char a[1000],b[1000],t[1000];
    int j,k=0,n,l,i,u=0;
    cin>>n;
    for(i=0; i<n; i++)
        cin>>a[i];
    for(i=0; i<n; i++)
        cin>>b[i];
    for(i=0; i<n+n; i++)
    {
        if(i%2==0)
        {
            t[i]=a[k];
            k++;
        }
        else if(i%2==1)
        {
            t[i]=b[u];
            u++;
        }
    }
    for(i=0; i<n+n; i++)
        cout<<t[i];
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include<math.h>
#include <iostream>
using namespace std;
int main(void){

	int A,B;
	cin >> A;
	cin >> B;

	if (A < 6) {
		cout << 0 << endl;
	}
	else if(A>12){
		cout << B << endl;
	}
	else {
		cout << B / 2 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int x[100001];
int gcd(int a,int b){
    if(a<b)return gcd(b,a);
    else if(a%b==0)return b;
    else return gcd(b,a%b);
}
int main(){
    int n;
    scanf("%d%d",&n,&x[0]);
    for(int i=1;i<=n;i++)scanf("%d",&x[i]);
    std::sort(x,x+(n+1));
    for(int i=n;i>0;i--)x[i]-=x[i-1];
    int ans=x[1];
    for(int i=2;i<=n;i++)ans=gcd(ans,x[i]);
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  double m = 100;
  ll x; cin>>x;

  double a = 1.01;
  ll ans = 0;
  while(m < x){
    ans++;
    m *= a;
    m = floor(m);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a;
cin>>a;
int l=a.length();
l-=2;
string b="",c="";
int lh=l/2,len;
while(1)
{
for(int i=0,j=lh;i<lh;i++,j++)
{
    b+=a[i],c+=a[j];
}
//cout<<b<<endl<<c<<endl;
if(c==b)
{
    len=b.length();
    break;
}
else
    {
        l-=2;
        lh=l/2;
        b="",c="";
    }

}
cout<<len*2;
}


Measured memory_bytes: 256