akhauriyash/Code-Regression huggingface dataset:
A,B,C,X,Y = map(int,input().split())
if A+B>=2*C:
    ans = 2*C*min(X,Y)
    if X>=Y:
        ans += (X-Y)*min(A,2*C)
    else:
        ans += (Y-X)*min(B,2*C)
else:
    ans = (A+B)*min(X,Y)
    if X>=Y:
        ans += (X-Y)*A
    else:
        ans += (Y-X)*B
print(ans)

Measured memory_bytes: 38256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    int n; cin >> n;
    map<string, bool> T;
    bool can = true;

    REP(i,n){
        string reg;
        cin >> reg;
        T[string(reg)] = true;
    }

    cout << T.size() << endl;
}

Measured memory_bytes: 19220
//Bismillahir Rahmanir Rahim
//In the name of Allah the Most Merciful
//Astagfirullahil laji Rabbi Minkulli Jamio
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define MX 1000007
int i,j,k;
main()
{
 int n;cin>>n;int a[n+1];
 for(i=1;i<=n;i++)cin>>a[i];
 int c=0;
 for(i=1;i<=n;i++)
 {
     if(i%2!=0&&a[i]%2!=0)c++;
 }
 cout<<c<<endl;
}


Measured memory_bytes: 3636
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


a, b, c = LI()
if a == b == c:
    if a % 2:
        print(0)
    else:
        print(-1)
else:
    ans = 0
    while True:
        if a % 2 or b % 2 or c % 2:
            break
        a, b, c = b // 2 + c // 2, a // 2 + c // 2, a // 2 + b // 2
        ans += 1
    print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<ios>
#include<iomanip>
//#include <boost/multiprecision/cpp_int.hpp>

//namespace mp = boost::multiprecision;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
vector<vector<int>>C;
//using Bint = mp::cpp_int;
typedef unsigned long long Bint;

Bint mpow(int n)
{
    Bint res=1;
    for(int i=0;i<n;i++)
    {
        res*=2;
    }
    return res;
}

int main()
{
    int N,P,O=0,E=0;
    cin>>N>>P;
    for(int i=0;i<N;i++)
    {
        int a;
        cin>>a;
        if(a%2)O++;
        else  E++;
    }
    if(P==0)
    {
        if(O>0)
            cout<<mpow(N-1)<<endl;
        else
            cout<<mpow(N)<<endl;
    }
    else
    {
        if(O==0)
            cout<<0<<endl;
        else
            cout<<mpow(N-1)<<endl;
    }
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');
  var params = inputs[0].split(' ').map(Number);

  (function(a, b) {
    console.log(a*b, (a+b)*2);// ????????????????????????

  })(params[0], params[1]);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15524
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e3+10;
int dis[N][N],vis[N];
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            dis[i][j]=j-i;
    for(int i=1;i<=x;i++)
        for(int j=y;j<=n;j++)
            dis[i][j]-=(y-x-1);
    for(int i=1;i<x;i++)
        for(int j=x;j<=y;j++)
            dis[i][j]=x-i+min(j-x,y-j+1);
    for(int i=x;i<=y;i++)
        for(int j=y+1;j<=n;j++)
            dis[i][j]=j-y+min(y-i,i-x+1);
    for(int i=x;i<=y;i++)
        for(int j=x+1;j<=y;j++)
            dis[i][j]=min(dis[i][j],i-x+y-j+1);
    memset(vis,0,sizeof(vis));
    //for(int i=1;i<=n;i++){
  //      for(int j=i+1;j<=n;j++) printf("%d ",dis[i][j]);printf("\n");
   // }

    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            vis[dis[i][j]]++;
    for(int i=1;i<n;i++) printf("%d\n",vis[i]);
    return 0;
}
/*
1 2 3 4 5 6 7  9 10
      8
1 2 3 4 5 5 4 5 6
1 2 3 4 4 3 4 5
1 2 3 3 2 3 4
1 2 2 1 2 3
1 2 2 3 4
1 2 3 4
1 2 3
1 2
1
*/



Measured memory_bytes: 16000
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 24 20:12:29 2018

@author: maezawa
"""

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

accum = [0]*(n+1)
sacc = 0
for i in range(n):
    sacc += a[i]
    accum[i+1] = sacc
#print(accum)
l=0
ndim = n*(n+1)//2
beauty = [] 
for i in range(1,n+1):
    for j in range(i,n+1):
        b = accum[j] - accum[i-1]        
        beauty.append(b)

beauty.sort(reverse=True)
#print(beauty)
ans = 0
kgroup = beauty[:]
nextkgroup = []
bt = 40
while True:
    cnt = 0
    btn = 1 << bt
    for i in kgroup:
        if i & btn != 0:
            nextkgroup.append(i)
            cnt += 1
    if cnt >= k:
        ans = ans | btn
        kgroup = nextkgroup[:]
    nextkgroup = []
    bt -= 1
    if bt < 0:
        break
    
print(ans)
    
        

Measured memory_bytes: 28576
import java.util.*;
import java.text.*;

public class Main{
	
	public static void main(String [] args) {
		Scanner sc = new Scanner(System.in);
		DecimalFormat df = new DecimalFormat("0.00000000000");
		long H = sc.nextLong(), W = sc.nextLong(), x = sc.nextLong(), y = sc.nextLong();
		double half = H/2.0*W;
		if(H/2.0 == x && W/2.0 == y) {
			System.out.println(df.format(half) + " " + 1);
		}
		else {
			System.out.println(df.format(half) + " " + 0);
		}
	}
	
}

Measured memory_bytes: 22864
#include<stdio.h>
#define n 100
int main(){

  int a,i,j,N,flag=1,A[n],count;

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  while(flag){
    flag=0;
   for(j=(N-1);j>0;j--){
      if(A[j-1]>A[j]){
	a = A[j-1];
	A[j-1] = A[j];
	A[j] = a;
	flag=1;
	count++;
      }
    }
  }
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
  return 0;
}



   




Measured memory_bytes: 2124
import sys
def input(): return sys.stdin.readline().rstrip()
import numpy as np
def main():
    h,n=map(int,input().split())
    lis=np.array([list(map(int,input().split())) for _ in range(n)])
    dp=np.zeros(10**4+1,int)
    dp[0]=0
    for i in range(1,h+1):
        dp[i]=np.min(dp[np.maximum(i-lis[:,0],0)]+lis[:,1])
    print(dp[h])

if __name__=='__main__':
    main()

Measured memory_bytes: 14568
#include<stdio.h>
int main()
{
    int a,b;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        if(a>=1 && a<=13 && b>=1 && b<=13)
        {
            if(a==b)
            {

                printf("Draw\n");
            }
            else if (a==1)
            {

                printf("Alice\n");
            }
            else if(b==1)
            {
                printf("Bob\n");
            }

            else if(a>b)
            {

                printf("Alice\n");
            }
            else if(a<b)
            {

                printf("Bob\n");
            }


        }


    }
    return 0;
}

Measured memory_bytes: 128
import sys
K,N=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())

L=[]
prev=None
for a in A:
    if prev is None:
        prev=a
    else:
        L.append(a-prev)
        prev=a
else:
    L.append(K-A[-1]+A[0])

print K-max(L)

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

int main(void) {
  vector<int> A(3);
  rep(i, 3) {
    cin >> A[i];
  }

  sort(A.begin(), A.end());

  cout << A[1] - A[0] + A[2] - A[1] << endl;
  
  return 0;
}

Measured memory_bytes: 3568
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            if (0 == N)
            {
                WriteLine("0");
                return;
            }
            var ans = new List<int>();
            while (N != 0)
            {
                if (Abs(N % 2) == 0) ans.Add(0);
                else
                {
                    if (N < 0) --N;
                    ans.Add(1);
                }
                N /= -2;
            }
            ans.Reverse();
            WriteLine(string.Join("", ans));
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28352
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int l, r, d;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> l >> r >> d;

  cout << (r / d - (l - 1) / d) << endl;
}


Measured memory_bytes: 3648
program answer
  implicit none
  integer(16) :: i, N, ans, a, b, c
  read(*,*) N

  i=0
  a=1
  b=1
  c=1
  do
     if(i==N) then
        exit
     end if
     a=mod(10*a,10**9+7)
     b=mod(9*b,10**9+7)
     c=mod(8*c,10**9+7)
     i=i+1
  end do

  a=mod(a-b,10**9+7)
  a=a+10**9+7
  a=mod(a-b,10**9+7)
  a=a+10**9+7
  ans=a+c
  ans=mod(ans,10**9+7)
  write(*,*) ans
  stop
 end program answer

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

gcd_val = A[0]
for a in A[1:]:
    gcd_val = gcd(gcd_val, a)
print(gcd_val)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


template <typename T>
class MedianQueue{
  public:
    priority_queue<T,vector<T>> leftQ;
    priority_queue<T,vector<T>,greater<T>> rightQ;
    MedianQueue() {}
    ~MedianQueue() {}
    void push(T x) {
        if (leftQ.empty() || x <= leftQ.top()) {
            leftQ.push(x);
        } else {
            rightQ.push(x);
        }
    }
    pair<T,T> get_median() {
        while (abs((int)leftQ.size() - (int)rightQ.size()) > 1) {
            if (leftQ.size() < rightQ.size()) {
                leftQ.push(rightQ.top());
                rightQ.pop();
            } else {
                rightQ.push(leftQ.top());
                leftQ.pop();
            }
        }
        if (leftQ.size() + 1 == rightQ.size()) {
            return {rightQ.top(), rightQ.top()};
        } else if (leftQ.size() == rightQ.size() + 1){
            return {leftQ.top(), leftQ.top()};
        } else {
            return {leftQ.top(), rightQ.top()};
        }
    }
};



int main(void){
    int Q;
    cin >> Q;
    MedianQueue<ll> qu;
    qu.push(-INF);
    qu.push(+INF);
    pair<ll,ll> med = qu.get_median();
    ll height = 0;
    rep(i,Q){
        int q;
        cin >> q;
        if (q == 1) {
            ll a,b;
            cin >> a >> b;
            height += b;
            qu.push(a);
            if (a < med.first || med.second < a) {
                height += min(abs(a - med.first), abs(a - med.second));
            }
            med = qu.get_median();
        } else {
            cout << med.first << " " << height << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
int arr[100005];
int arr2[100005];
//ll Pow(ll base , ll power)
//void sieve_eratosthenes(int n);
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n ,x,y ;
cin>>n>>x>>y;

for(int i = 1 ;i<n;i++)
{
    for(int j=i+1;j<=n;j++)
    {
        int distance  = min(abs(x-i)+abs(y-j)+1,j-i) ;
        arr[distance]++;
    }
}
for(int i=1;i<n;i++)cout<<arr[i]<<endl;
}

/*
void sieve_eratosthenes(int n)
    {
bool primes[n+2]={false};
for(int i=3;i<=n;i+=2)
    primes[i]=1;
    primes[2]=1;
for(int i=3;i*i<=n;i+=2)
{
    if(primes[i]==1){
    for(int j=i*i;j<=n;j+=i)
        primes[j]=0;
    }
}
for(int i=2;i<=n;i++)
    if(primes[i]==1)
    cout<<i<<endl;
return;
    }
ll Pow(ll base , ll power)
        {
            if(power==0)return 1;
            ll x = Pow(base,power/2);
            x*=x;
            if(power&1)
                return base*x;
            else
                return x;
        }
*/


Measured memory_bytes: 256
N = input()
S = input()
K = input()

char = S[int(K)-1]

#print(char)

ans = []

for j in range(len(S)):
  #print(S[j])
  if char != S[j]:
    ans.append("*")
    #print("!=")   
  else:
    ans.append(char)
    continue

print("".join(ans))


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

long long int mem[100005][4];
vector<int> a,b,c;
int n;

long long int dp(int i,int m){
	if(i>n-1)
	{
		return 0;
	}
	if(mem[i][m]!=-1)
	{
		return mem[i][m];
	}
	long long int ans;
	if(m==1){
		ans = max(dp(i+1,2)+a[i],dp(i+1,3)+a[i]);
	}
	if(m==2){
		ans = max(dp(i+1,1)+b[i],dp(i+1,3)+b[i]);
	}
	if(m==3){
		ans = max(dp(i+1,1)+c[i],dp(i+1,2)+c[i]);
	}
	mem[i][m]=ans;
	return ans;
}


int main()
{
	memset(mem,-1,sizeof(mem));
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		a.push_back(x);
		b.push_back(y);
		c.push_back(z);
	}
	cout<<max(dp(0,1),max(dp(0,2),dp(0,3)));
	return 0;
}

Measured memory_bytes: 12336
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }

  template< typename C >
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while(a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if(check(nxt)) a = 2 * a + type;
      else M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }


  template< typename C >
  int find_first(int a, const C &check) {
    Monoid L = M1;
    if(a <= 0) {
      if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) {
        Monoid nxt = f(L, seg[a]);
        if(check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template< typename C >
  int find_last(int b, const C &check) {
    Monoid R = M1;
    if(b >= sz) {
      if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for(b += sz; a < b; a >>= 1, b >>= 1) {
      if(b & 1) {
        Monoid nxt = f(seg[--b], R);
        if(check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};


bool solve(){
	ll x;cin>>x;
	cout<<lcm(360,x)/x<<endl;
	return false;
}

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


Measured memory_bytes: 3648
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

// conversion
inline int
toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

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

//math
template <class T>
inline T sqr(T x) { return x * x; }

template <class T>
inline T nCr(T n, T r)
{
    T num = 1;
    for (int i = 1; i <= r; ++i)
    {
        num *= (n - i + 1) / i;
    }
    return num;
}
template <class T>
inline T nPr(T n, T r)
{
    r = n - r;
    T sum = 1;
    int i;
    for (i = n; i >= r + 1; --i)
        sum *= i;
    return sum;
}

template <class T>
inline T facctorial(T k)
{
    T sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

//numeric
template <class T>
inline T gcd(T a, T b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

template <class T>
inline T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())

//repetition
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
constexpr double EPS = 1e-10;
const double PI = acos(-1.0);
constexpr LL INF = 1e10;

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
void print_vector(vector<int> &x)
{
    for (int i = 0; i < x.size(); ++i)
    {
        dump(x[i]);
    }
    cout << endl;
}

int main()
{
    int n, m;
    cin >> n >> m;
    priority_queue<int> a;
    for (int i = 0; i < n; ++i)
    {
        int in;
        cin >> in;
        a.push(in);
    }
    for (int i = 0; i < m; ++i)
    {
        int temp;
        temp = a.top();
        temp /= 2;
        a.pop();
        a.push(temp);
    }
    LL ans = 0;
    for (int i = 0; i < n; ++i)
    {
        ans += a.top();
        a.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
package main

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

// const abcd = "abcdefghijklnmopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}
var inf int = 1e9

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	n := next.Line()
	ans := "No"
	for i := 0; i < len(n); i++ {
		if n[i] == '9' {
			ans = "Yes"
		}
	}
	fmt.Println(ans)
}

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

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(s: str, t: str):
    len_s = len(s)
    len_t = len(t)

    dp = [[0] * (len_t+1) for _ in range(len_s+1)]

    for i in range(len_s):
        for j in range(len_t):
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])

    ans = []
    while len_s > 0 and len_t > 0:
        if s[len_s-1] == t[len_t-1]:
            ans.append(s[len_s-1])
            len_s -= 1
            len_t -= 1
        elif dp[len_s][len_t] == dp[len_s-1][len_t]:
            len_s -= 1
        else:
            len_t -= 1

    print("".join(reversed(ans)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    t = next(tokens)  # type: str
    solve(s, t)


if __name__ == '__main__':
    main()


Measured memory_bytes: 111708
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
    int n;
    string ans = "Yes";
    map<string,bool>m;
    cin >> n;

    for(int i = 0;i < n;i++){
        string s;
        char tmp1;
        cin >> s;
        if(i != 0 && s.front() != tmp1){
            ans = "No";
        }
        if(m.find(s) == m.end())
            m[s] = true;
        else {
            ans = "No";
        }
        tmp1 = s.back();
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
P = gets.chomp.split.map(&:to_i).join("")
Q = gets.chomp.split.map(&:to_i).join("")
a = 0
b = 0

[*1..n].permutation.each_with_index do |perm, idx|
    a = idx if P == perm.join("")
    b = idx if Q == perm.join("")
end

puts (a-b).abs

Measured memory_bytes: 14236
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	string s;
	long long k, co1 = 0;
	long long ans = 0;
	long long o = 0, t = 0;
	cin >> s >> k;
	string s1 = s + s;
	for (int c = 1; c < s.size(); c++) {
		if (s[c] != s[c - 1]) {
			break;
		}
		else {
			co1++;
		}
	}
	if (co1 == s.size() - 1) {
		ans = s.size() * k / 2;
		cout << ans << endl;
		return 0;
	}
	for (int i = 1; i < s.size(); i++) {
		if (s[i] == s[i - 1]) {
			s[i] = '0';
			o++;
		}
	}
	for (int j = 1; j < s1.size(); j++) {
		if (s1[j] == s1[j - 1]) {
			s1[j] = '0';
			t++;
		}
	}
	t = t - o;
	ans = o + (k - 1) * t;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
inline ll getll() {
	ll A = 0;
	if (ci - cn + 24 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	ll N = getint(), K = getll();
	int A[200000], F[200000];
	rep(i, N) A[i] = getint();
	rep(i, N) F[i] = getint();
	pakuri_sort(N, A);
	pakuri_sort(N, F);

	ll L = -1, R = 1e12;
	while (L + 1 < R) {
		ll M = (L + R) / 2;

		ll kazu = 0;
		rep(i, N) {
			int f = F[N - i - 1];
			kazu += (max((ll)A[i] * f - M, 0ll) + f - 1) / f;
			if (kazu > K) break;
		}
		if (kazu > K) L = M;
		else R = M;
	}

	printf("%lld", R);


	Would you please return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    cout << 180 * (N - 2) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	static Scanner in;
	static PrintWriter out;
	static void solve() {
		int answer = 0;
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		if (a < b) {
			answer += a;
			if(b < c) {
				answer += b;
				out.println(answer);
				return;
			}
			answer += c;
			out.println(answer);
			return;
		}
		answer += b;
		if (a < c) {
			answer += a;
			out.println(answer);
			return;
		}
		answer += c;
			out.println(answer);
			return;
	}
	public static void main(String[] args) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
		out.close();
		in.close();
	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s;
    cin >> s;
    cout << count(ALL(s), '1') << endl;

    return 0;
}

Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
X=int(input())
total = 0
cnt = 0
 
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      total = 500*a+100*b+50*c
      if total==X:
        cnt +=1
             
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int INF_INT = 1e9;

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

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int d,t,s;
    cin >> d >> t >> s;
    if(d <= t * s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
program sample1
      implicit none
      
      integer(8) N,K,L1,L2
      read(*,*) N,K
      L1=mod(N,K)
      L2=-(L1-K)
      if (L1>L2) then
      write(*,'(i0)') L2
      else 
      write(*,'(i0)') L1
      end if
      stop 
      end program sample1





Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
struct node
{
    int cnt;
    int nx[26];
    node()
    {
        cnt=0;
        fill(nx,nx+26,0);
    }
}tr[1000010];
int tct;
void upd(int n,const string&s,int ind)
{
    if(ind==0)
    {
        tr[n].cnt++;
        return;
    }
    int nx=s[ind]-'a';
    if(tr[n].nx[nx]==0)
        tr[n].nx[nx]=++tct;
    upd(tr[n].nx[nx],s,ind-1);
    return;
}
int get(int n,const string&s,int ind,int mind)
{
    if(n==0)
        return 0;
    if(ind==mind)
        return tr[n].cnt;
    int nx=s[ind]-'a';
    return tr[n].cnt+get(tr[n].nx[nx],s,ind-1,mind);
}
int rt[26];
int chk[26];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<string>v(n);
    for(string&t:v)
        cin>>t;
    sort(all(v),[](const string&x,const string&y){return x.size()<y.size();});
    for(int i=0;i<26;i++)
        rt[i]=++tct,chk[i]=-1;
    ll ans=0;
    for(string&s:v)
    {
        for(int i=0;i<(int)s.size();i++)
            if(chk[s[i]-'a']==-1)
                chk[s[i]-'a']=i;
        for(int i=0;i<26;i++)
            if(chk[i]!=-1)
                ans+=get(rt[i],s,(int)s.size()-1,chk[i]);
        for(int i=0;i<(int)s.size();i++)
            chk[s[i]-'a']=-1;
        upd(rt[s[0]-'a'],s,(int)s.size()-1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 114840
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228

const int N = 777;

bool con[N][N];
vector<int> g[N];

int white = 0, black = 0;
int color[N];

void dfs(int v, int col = 1) {
	color[v] = col;
	if (color[v] == 1) ++white;
	else ++black;
	for (int to : g[v]) {
		if (color[to] == color[v]) {
			cout << -1 << '\n';
			exit(0);
		}
		if (!color[to]) {
			dfs(to, 3 - col);
		}
	}
}

bitset<N> dp;

ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		con[u][v] = con[v][u] = 1;
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			con[i][j] = !con[i][j];
			if (i != j && con[i][j]) {
				g[i].push_back(j);
			}
		}
	}
	dp[0] = 1;
	for (int i = 1; i <= n; ++i) {
		if (!color[i]) {
			white = black = 0;
			dfs(i);
			dp = ((dp << white) | (dp << black));
		}
	}
	int res = n * (n - 1) / 2 + n * (n - 1) / 2 + 100;
	for (int i = 0; i <= n; ++i) {
		if (dp[i]) {
			uin(res, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
		}
	}
	cout << res << '\n';
    return 0;
} // kek ;


Measured memory_bytes: 6400
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 1000000000

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void swap2(double* a, double* b)
{
	double tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int gcd(int a, int b)
{
	if (a < b)
		swap(&a, &b);

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

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


int main()
{
	int N;
	char a[11];

	int count=0;
	int max = 0;

	vector<string> S;

	scanf("%d", &N);

	for (int i = 0; i < N; i++)
	{
		scanf("%s", a);
		S.push_back(a);
	}

	sort(S.begin(), S.end());

	for (int i = 0; i < N-1; i++)
	{
		if (S[i] == S[i + 1])
			count++;

		if (count > max)
			max = count;

		if (S[i] != S[i + 1])
			count = 0;
	}

	count = 0;

	for (int i = 0; i < N -1; i++)
	{
		if (S[i] == S[i + 1])
			count++;

		if (S[i] != S[i + 1])
			count = 0;

		if (count == max)
			cout << S[i] << endl;


	}
	if (max == 0)
		cout << S[N-1] << endl;

	//for (int i = 0; i < N; i++)
		//cout << S[i] << endl;
}

Measured memory_bytes: 8560
n = int(input())
a = list(map(int,input().split()))
ans = []
if n%2==0:
  front = a[::2]
  back = a[1::2][::-1]
else:
  front = a[1::2]
  back = a[::2][::-1]
ans = back+front
print(*ans)

Measured memory_bytes: 26180
import itertools, math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

c = 0
for i, j in itertools.combinations(range(n), 2):
    d = sum((y - z) ** 2 for y, z in zip(x[i], x[j]))
    if d == math.floor(math.sqrt(d)) ** 2:
        c += 1

print(c)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 100001
using namespace std;
vector<pair<int,int> > A(MAX, pair<int,int>(0,0));
vector<pair<int,int> > B(MAX, pair<int,int>(0,0));

int main() {
  int n,i;
  cin >> n;
  for(i=0;i<n;i++) {
    int v;
    cin >> v;
    if(i%2==0) {
      A[v].second = v;
      A[v].first++;
    } else {
      B[v].second = v;
      B[v].first++;
    }
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());

  if(A[MAX-1].second==B[MAX-1].second) {
    if(A[MAX-1].first < B[MAX-1].first) {
      cout << n-A[MAX-2].first-B[MAX-1].first << endl;
    } else if(A[MAX-1].first > B[MAX-1].first){
      cout << n-A[MAX-1].first-B[MAX-2].first << endl;
    } else {
      cout << n-A[MAX-1].first-max(A[MAX-2].first,B[MAX-2].first) << endl;
    }
  }else {
    cout << n-A[MAX-1].first-B[MAX-1].first << endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans;
int n,m;

signed main(){
	string s,t,kt;
	cin>>s;
	rep(i,s.size()){
		if(s[i]!='x')t+=s[i];
	}
	kt=t;
	reverse(t.begin(),t.end());
	if(t!=kt){
		cout<<-1<<endl;
		return 0;
	}
	int i=0,j=s.size()-1;
	while(i<j){
		if(s[i]!=s[j]){
			ans++;
			if(s[i]=='x')i++;
			else j--;
		}
		else{
			i++;j--;
		}
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    map<ll, int> m;
    for (ll l : v) m[l]++;

    if (m.find(0) != m.end() && m[0] == n) {
        cout << "Yes" << endl;
        ret();
    }

    vector<ll> keys;
    for (auto e : m)keys.push_back(e.first);

    if (keys.size() == 2 && keys[0] == 0 && m[0] * 3 == n) {
        cout << "Yes" << endl;
        ret();
    }

    if (keys.size() == 3 && m[keys[0]] * 3 == n && m[keys[1]] * 3 == n && m[keys[2]] * 3 == n &&
        (keys[0] ^ keys[1] ^ keys[2]) == 0) {
        cout << "Yes" << endl;
        ret();
    }
    cout << "No" << endl;
}


Measured memory_bytes: 9660
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
	int N;
	cin >> N;
	cout << (N + 1) / 2;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i, a, b) for(LL i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1000000007;
const LL MAXN = 1e5 + 47;
const LL MAX = 1e5 + 47;

LL n, k;
string s;
deque<int> d;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	cin >> n >> k >> s;
	FOR(i, 0, n)
		if (s[i] == 'A')
			d.push_back(1);
		else
			d.push_back(0);

	int rev = 0;
	int MAGIC = 100 + 2 * n;

	if (k < MAGIC)
	{
		REP(q, k)
		{
			if (d[0] ^ rev)
				d[0] ^= 1;
			else
			{
				d.pop_front();
				d.push_back(rev);
				rev ^= 1;
			}
		}
	}
	else
	{
		int cnt = k - MAGIC;
		REP(q, MAGIC)
		{
			if (d[0] ^ rev)
				d[0] ^= 1;
			else
			{
				d.pop_front();
				d.push_back(rev);
				rev ^= 1;
			}
		}

		if (cnt & 1)
		{
			if (d[0] ^ rev)
				d[0] ^= 1;
			else
			{
				d.pop_front();
				d.push_back(rev);
				rev ^= 1;
			}
		}
	}

	for (auto i : d)
		if (i ^ rev)
			cout << "A";
		else
			cout << "B";

	cin >> s;
	return 0;
}

Measured memory_bytes: 1560
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

int h, w, k;

int solve(const vector<string>& mat) {
    int res = 0;
    for(int i = 0; i < (1 << h); ++i)
    {
        for(int j = 0; j < (1 << w); ++j)
        {
            int count_black = 0;
            for(int x = 0; x < h; ++x) {
                for(int y = 0; y < w; ++y) {
                    int banned = 0;
                    if(i & (1 << x)) banned++;
                    if(j & (1 << y)) banned++;
                    if(banned == 0 && mat[x][y] == '#') count_black++;
                }
            }
            if(count_black == k) res++;
        }
    }
    return res;
}

// End of template code!
int main() 
{
    buff();
    cin >> h >> w >> k;
    vector<string> mat(h);
    rep(i, 0, h) cin >> mat[i];
    cout << solve(mat) << '\n';

    return 0;
}



Measured memory_bytes: 3644
package main

import (
	"errors"
	"fmt"
)

func main() {
	nl := scanInts(2)
	n, l := nl[0], nl[1]
	as := scanInts(n)

	knot, err := int64(0), errors.New("")
	for i := range iter(0, n-1) {
		if as[i]+as[i+1] >= l {
			knot, err = i, nil
			break
		}
	}
	if err != nil {
		fmt.Println("Impossible")
	} else {
		fmt.Println("Possible")
		for i := range iter(0, knot) {
			fmt.Println(i + 1)
		}
		for i := range iter(0, n-knot-2) {
			fmt.Println(n - 1 - i)
		}
		fmt.Println(knot + 1)
	}
}

func scanInts(length int64) []int64 {
	ints := make([]int64, length)
	for i := range iter(0, length) {
		var x int64
		_, _ = fmt.Scan(&x)
		ints[i] = x
	}
	return ints
}

func iter(l int64, r int64) chan int64 {
	var i int64 = l
	c := make(chan int64)
	run := func() {
		for i < r {
			c <- i
			i += 1
		}
		close(c)
	}
	go run()
	return c
}

func gcd(a int64, b int64) int64 {
	x, y := a, b
	for true {
		if x%y == 0 {
			break
		}
		x, y = y, x%y
	}
	return y
}

func slice_gcd(ints []int64) int64 {
	return reduce_int(gcd, ints)
}

func lcm(a int64, b int64) int64 {
	g := gcd(a, b)
	return a * b / g
}

func slice_lcm(ints []int64) int64 {
	return reduce_int(lcm, ints)
}

func reduce_int(f func(int64, int64) int64, ints []int64) int64 {
	ans := ints[0]
	for i := range iter(1, int64(len(ints))) {
		ans = f(ans, ints[i])
	}
	return ans
}


Measured memory_bytes: 7296