akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	string s,t,u;
	int a,b; cin>>s>>t>>a>>b>>u;
	if(u==s) a--;
	if(u==t) b--;
	cout<<a<<' '<<b<<'\n';
	return 0;
}


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

int main() {
  ll N;
  cin >> N;
  ll p = (N-1)/11;
  ll q = (N-1)%11;
  cout << (q > 5 ? p*2 + 2 : p*2 +1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL x[100];
LL y[100];
LL xx[100];
LL yy[100];
int main(){
	LL N,M;
	cin>>N>>M;
	REP(i,N){
	    cin>>x[i]>>y[i];
	}
	REP(i,M){
	    cin>>xx[i]>>yy[i];
	}
	REP(i,N){
	    LL dis=1000000000000000;
	    LL num=-1;
	    REP(j,M){
	        LL temp=abs(x[i]-xx[j])+abs(y[i]-yy[j]);
	        if(dis>temp){
	           dis=temp;
	           num=j;
	        }
	    }
	    cout<<num+1<<endl;
	}
	return(0);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    int count = 0;

    int n = sc.nextInt();

    for(int i = 0; i < n ; i++){
        list.add(sc.nextInt());
    }

    for(int i = 1; i < n - 1; i++){
        if(list.get(i - 1) < list.get(i) && list.get(i) < list.get(i + 1)){
            count++;
        }
        if(list.get(i - 1) > list.get(i) && list.get(i) > list.get(i + 1)){
            count++;
        }
    }

    System.out.println(count);









    
    






    

    



    
  

    


    


    

    
    
    



    





}
}

Measured memory_bytes: 35688
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    set<ll>S;
    ll N;
    cin >> N;
    rep(i, N){
        ll x;
        cin >> x;
        S.insert(x);
    }
    if(S.size() == N)cout << "YES" << endl;
    else cout << "NO" << endl;
    
    
    return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,v;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  

  for(i=1;i<=n;i++){
    v = A[i];
    j = i-1;
    while( (0<=j) && (A[j]>v) ){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }trace(A, n);
  }
  
  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+7;
ll mod=1e9+7;
ll a[maxn];
ll qpow(ll a,ll b){
    long long res=1,t=a;
    while(b){
        if(b&1) res=(res*t)%mod;
        t=(t*t)%mod;
        b>>=1;
    }
    return res;
}
int main()
{
    int n,x;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        a[x]++;
    }
    if(n%2==0){
        for(int i=1;i<=n;i+=2){
            if(a[i]!=2)
            {
                cout<<"0"<<endl;
                return 0;
            }
        }
        cout<<qpow(2,n/2)<<endl;
        return 0;
    }
    else if(n%2){
        if(a[0]!=1){
            cout<<"0"<<endl;
            return 0;
        }
        else{
            for(int i=2;i<=n;i+=2){
                if(a[i]!=2){
                    cout<<"0"<<endl;
                    return 0;
                }
            }
            cout<<qpow(2,n/2)<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = ['']*n
for i in range(n):
    a[i] = int(input())
_a = sorted(a, reverse=1)
a_max = _a[0]
a_second = _a[1]
ans = [a_max] * n

for i in range(n):
    if a[i] == a_max:
        ans[i] = a_second
    else:
        pass

print(*ans, sep='\n')

Measured memory_bytes: 23160
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

/*
 * if n > 2 * m ans = m / 2
 * else you can give (m - 2 * n) / 3
 */
int main() {
	ll n, m;
	cin >> n >> m;
	if (n > m / 2) {
		cout << m / 2;
	}
	else {
		cout << n + (m - 2 * n) / 4;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] b = new int[2];
        for(int i=0; i < a; i++) {
            String s1 = sc.next();
            String s2 = sc.next();
            if(s1.compareTo(s2) > 0) {
                b[0] += 3;
            }
            else if(s1.compareTo(s2) < 0) {
                b[1] += 3;
            }
            else {
                b[0]++;
                b[1]++;
            }
        }
        System.out.println(b[0] + " " + b[1]);
    }
}


Measured memory_bytes: 29356
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int ddx[6]={0,1,0,-1,1,-1},ddy[6]={-1,0,1,0,1,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int d[100100];

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

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

int h,w;
char a[1000][1000];
int b[1000][1000];
int cnt=0;



int main(){

  queue<int> que;
  cin>>h>>w;
  rep(i,h)
  rep(j,w){
    cin>>a[i][j];
    if(a[i][j]=='#') que.push(i),que.push(j),b[i][j]=0;
    else b[i][j]=inf;
  }

  while(!que.empty()){
    int y=que.front();
    que.pop();
    int x=que.front();
    que.pop();

    int dx[4]={-1,0,0,1};
    int dy[4]={0,-1,1,0};
    rep(i,4){
      int nx=x+dx[i],ny=y+dy[i];
      if(nx>=0 && nx<w && ny>=0 && ny<h && a[ny][nx]=='.' && b[ny][nx]==inf){
        que.push(ny),que.push(nx);
        b[ny][nx]=b[y][x]+1;
        cnt=max(cnt,b[ny][nx]);
      }
    }
  }

  cout<<cnt<<endl;
}

Measured memory_bytes: 13328
#include <bits/stdc++.h>
using namespace std;
 
bool p[1010000];
 
void prime() {
  fill(p, p+1010000, true);
  p[0] = false;
  p[1] = false;
  for(int i = 2; i < 1010000; i++) {
    if(p[i]) {
      for(int j = 2; i*j < 1010000; j++) {
    p[i*j] = false;
      }
    }
  }
}
 
int search(int n, int m) {
  vector<int> a;
  int cnt = 0;
  for(int i = n+1; ; i++) {
    if(p[i]) {
      a.push_back(i+i);
      cnt++;
      if(cnt == m+10000) {
    sort(a.begin(), a.end());
    return a[m-1];
      }
      if(p[i]) {
    for(int j = n+1; j < i; j++) {
      if(p[j]) {
        a.push_back(i+j);
        cnt++;
        if(cnt == m+10000) {
          sort(a.begin(), a.end());
          return a[m-1];
        }
      }
    }
      }
    }
  }
}
 
int main() {
  int n, m;
  prime();
 
  while(cin >> n >> m, n+m != -2) {
    int ans = search(n, m);
    cout << ans << endl;
  }
}

Measured memory_bytes: 2308
#include <bits/stdc++.h>
using namespace std;
int main() {
    int k, sum=0;
	vector<int> v1(3);
	for(int i=0;i<3;i++)
	{
	    cin>>v1[i];
	}
		cin>>k;
	sort(v1.begin(),v1.end());
	for(int i=1;i<=k;i++){
	v1[2]=v1[2]*2;}
	for(int i=0;i<3;i++)
	{
	    sum+=v1[i];
	}
    cout<<sum<<"\n";
	return 0;
}


Measured memory_bytes: 3532
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// dfsで参考に
// https://atcoder.jp/contests/abc150/submissions/14621223
// https://www.qoosky.io/techs/09116bea96

var N int
var P, Q, base []int
var used []bool
var cnt, Pn, Qn int

func main() {
	N = nextInt()
	P = make([]int, N)
	Q = make([]int, N)
	// var Pn, Qn, cnt int
	for i := range P {
		P[i] = nextInt()
	}
	for i := range Q {
		Q[i] = nextInt()
	}
	A := make([]int, 0)
	base = make([]int, N)
	copy(base, P)
	sort.Ints(base)
	used = make([]bool, N)
	for i := 0; i < N; i++ {
		dfs(A)
		if Pn != 0 && Qn != 0 {
			fmt.Println(abs(Pn - Qn))
			return
		}
	}
}

func dfs(A []int) {
	if len(A) == N {
		cnt++
		if reflect.DeepEqual(A, P) {
			Pn = cnt
		}
		if reflect.DeepEqual(A, Q) {
			Qn = cnt
		}
		// fmt.Println(A, Pn, Qn, cnt)
		return
	}
	for i := 0; i < N; i++ {
		if !used[i] {
			used[i] = true
			A = append(A, base[i])
			// fmt.Println("A", A)
			dfs(A)
			A = A[:len(A)-1]
			used[i] = false
		}
	}
}

func check(A []int) {

}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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

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

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


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

using namespace std;



int main(){

int a ,b;
cin >> a >> b;
int s=1;
	int i=0;
	if(b==1){
		cout<<i<<endl;
	}
	else{
		for(int k = 0; k < 20 ; k ++ ){
			s += (a-1);
			i++;
			if(s<b){
				continue;
			}
			else{
				break;
				}
	}

	cout<<i<<endl;
	}
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a+b==15){
    cout << '+' << endl;
  }
  else if(a*b == 15){
    cout << '*' << endl;
  }
  else {
    cout << 'x' << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] x = new int[n];
        int[] y = new int[n];
        for(int i = 0;i < n;i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        if(n == 1){
            System.out.println(1);
            System.exit(0);
        }

        Set<Tuple> pqset = new HashSet<>();
        for(int i = 0;i < n;i++) {
            for (int j = i + 1; j < n; j++) {
                pqset.add(new Tuple(x[i] - x[j], y[i] - y[j]));
            }
        }

        int ans = Integer.MAX_VALUE;
        for(Tuple t : pqset){
            int cost = n;
            for(int i = 0;i < n;i++) {
                for (int j = 0; j < n; j++) {
                    if(i == j){
                        continue;
                    }
                    if(t.getX() + x[j] == x[i] && t.getY() + y[j] == y[i]){
                        cost--;
                    }
                }
            }
            ans = Math.min(ans, cost);
        }
        System.out.println(ans);
    }

    public static class Tuple{
        int x;
        int y;

        public Tuple(int x, int y){
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        @Override
        public boolean equals(Object obj) {
            Tuple t = (Tuple)obj;
            return this.x == t.x && this.y == y;
        }
    }
}



Measured memory_bytes: 25428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const long double EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    vc<ll> dx = {0, 1, 0, -1}, dy = {1, 0, -1, 0};
    ll H, W;
    cin >> H >> W;
    vc<string> G(H);
    rep(i, H) cin >> G[i];

    ll ans = 0;
    queue<pair<ll, ll>> q;
    rep(i, H) rep(j, W) {
        if (G[i][j] == '#') continue;
        vvc<ll> dist(H, vc<ll>(W,INF));
        dist[i][j] = 0;
        q.emplace(i, j);

        while (!q.empty()) {
            ll h, w;
            tie(h, w) = q.front();
            q.pop();
            rep(d, 4) {
                ll hh = h + dx[d], ww = w + dy[d];
                if (hh < 0 || hh > H - 1 || ww < 0 || ww > W - 1) continue;
                if (G[hh][ww] == '#') continue;
                if (dist[hh][ww] > dist[h][w] + 1) {
                    dist[hh][ww] = dist[h][w] + 1;
                    q.emplace(hh, ww);
                }
            }

            ll tmp = 0;
            rep(s, H) rep(t, W) if (dist[s][t] != INF) tmp = max(tmp, dist[s][t]);
            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
<?php

// ファイルパス指定し、任意のファイルを読み取り専用でファイルオープン

fscanf(STDIN, "%d %d", $a, $b);
$arr = [];
while ($line = fgets(STDIN)){
    array_push($arr, $line);
}

$ans = [];
for ($i = 0; $i < count($arr); $i++) {
     $text = str_replace("\r\n", '', $arr[$i]);
     array_push($ans, $text);
     array_push($ans, $text);
}

for ($i = 0; $i < count($ans); $i++) {
    echo $ans[$i] . "\n"; 
}

?>

Measured memory_bytes: 16200
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

main = do
  [n, t] <- map read . words <$> getLine :: IO [Int]
  input <- getIntListBC
  print $ solve t input

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getIntListBC :: IO [Int]
getIntListBC = map bsToInt . BC.words <$> BC.getLine

solve :: Int -> [Int] -> Int
solve t (_:[])   = t
solve t (x:y:ys) = if y > x + t then t + solve t (y:ys)
                                else (y - x) + solve t (y:ys)


Measured memory_bytes: 8060
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N,K,ans=0;
    cin>>N>>K;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        ans+=(a<abs(a-K))? a:abs(a-K);
    }
    cout<<ans*2<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 int main(void){
     int k,a,b,l=1;
     scanf("%d",&k);
     scanf("%d %d",&a,&b);
     for(int i=a;i<=b;i++){
         if(i%k==0){
             printf("OK");
             return 0;
         }
     }
     printf("NG");
     return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
namespace mint {
  constexpr int md = 1e9 + 7;
  inline void add (int &a, int b) {
    a += b; if (a >= md) a -= md;
  }
  inline void sub (int &a, int b) {
    a -= b; if (a < 0) a += md;
  }
  inline int sum (int a, int b) {
    add(a, b); return a;
  }
  inline int dif (int a, int b) {
    sub(a, b); return a;
  }
  inline int prod (int a, int b) {
    return (int)((long long)a * b % md);
  }
  inline void mul (int &a, int b) {
    a = prod(a, b);
  }
  inline int inv (int a) {
    a %= md;
    if(a < 0) a += md;
    int b = md, u = 0, v = 1;
    while (a) {
      int t = b / a;
      b -= a * t; swap(a, b);
      u -= v * t; swap(u, v);
    }
    assert(b == 1);
    if(u < 0) u += md;
    return u;
  }
  inline int quat (int a, int b) {
    return prod(a, inv(b));
  }
  inline void div (int& a, int b) {
    a = quat(a, b);
  }
  inline int pow (int a, long long b) {
    int res = 1;
    for (; b; b >>= 1) {
      if (b & 1) mul(res, a);
      mul(a, a);
    }
    return res;
  }
}
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int>> dp(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dp[i][j] = a[i] > a[j] ? 1 : 0;
    }
  }
  int inv2 = mint::inv(2);
  int coeff = mint::pow(2, q);
  while (q--) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    auto half = [&] (int& a, int& b) -> void {
      mint::add(a, b);
      a = b = mint::prod(a, inv2);
    };
    half(dp[x][y], dp[y][x]);
    for (int z = 0; z < n; z++) if (z != x && z != y) {
      half(dp[x][z], dp[y][z]);
      half(dp[z][x], dp[z][y]);
    }
  }
  int ret = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      mint::mul(dp[i][j], coeff);
      mint::add(ret, dp[i][j]);
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 37596
#include<bits/stdc++.h>
using namespace std ;
#define ll long double
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n ;
  cin >> n ;
  ll arr[n] ;
  for(int i = 0 ; i < n ; i++) cin >> arr[i] ;
  sort(arr , arr + n) ;
  ll sum = arr[0] ;
  for(int i = 1 ; i < n ; i++){
    sum = (sum + arr[i])/2 ;
  }
  cout << sum ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    int ans = 10000;
    
    cin >> S;
    
    for(int i = 0; i < S.size()-2; i++){
        int num;
        num = stoi(S.substr(i,3));
        ans = min(ans,abs(num-753));
    }
    
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

set<int> yakusu(int x) {
	set<int> tmp;
	for (int i = 1;i <= sqrt(x);i++) {
		if (x%i == 0) {
			tmp.insert(i);
			tmp.insert(x / i);
		}
	}
	return tmp;
}

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

	int N, X;
	cin >> N >> X;
	set<int> dis;
	REP(i, N) {
		int x;
		cin >> x;
		x = abs(x-X);
		dis.insert(x);
	}
	set<int> y = yakusu(*dis.begin());
	set<int>::iterator res = y.end();
	res--;
	
	bool flag = true;
	while (flag) {
		for (set<int>::iterator itr = dis.begin();itr != dis.end();++itr) {
			if (*itr%*res != 0) {
				res--;
				break;
			}
			
			set<int>::iterator end = dis.end();
			if (itr == --end) flag = false;
		}
	}
	cout << *res << "\n";

	return 0;
}

Measured memory_bytes: 4864
//I̲n̲ ̲t̲h̲e̲ ̲N̲a̲m̲e̲ ̲o̲f̲ ̲G̲o̲d̲
#define pb push_back
#define F first
#define S second
#define sz size()
#define ll long long

#include <bits/stdc++.h>

using namespace std;

ll a, b, c;

int main()
{
	ios_base::sync_with_stdio(0);
	cin >> a >> b >> c;
	if (a <= c && c <= b)
        return cout << "Yes" , 0;
    cout << "No" ;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <bitset>


const int kN = 8000 + 5;
char s[kN];
int x, y;
std::vector<int> vec[2];
const int base = 20000;

bool solve(const std::vector<int> &vec, int aim, int sure = 0)
{
    aim += base;
    for (int i = 0; i < sure && i < vec.size(); ++ i)
        aim -= vec[i];
    std::bitset<base * 2 + 100> bs;
    bs[base] = 1;
    for (int i = sure; i < vec.size(); ++ i) {
        int x = vec[i];
        bs = bs << x | bs >> x;
    }
    return bs[aim] == 1;
}

int main()
{
    scanf("%s", s);
    scanf("%d%d", &x, &y);
    int d = 0, w = 0;
    for (int i = 0; s[i]; ++ i) {
        if (s[i] == 'T') {
            vec[d].push_back(w);
            d ^= 1;
            w = 0;
        } else {
            w ++;
        }
    }
    if (w)
        vec[d].push_back(w);
    puts(solve(vec[0], x, 1) && solve(vec[1], y) ? "Yes" : "No");
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

typedef stringstream ss;
template<class T> inline string toStr(T f){ ss sss; sss << f; return sss.str(); }

int main(){
  
  int n;
  while(cin >> n, n){
    string now, prev; cin >> prev;
    
    for(int i = 0; i < n; i++){
      int cnt;
      for(int j = 0; j < prev.size(); j+=cnt){
	cnt = 0;
	for(int k = j; prev[k] == prev[j]; k++, cnt++);
	now.append(toStr(cnt));
	now.append(1, prev[j]);
      }
      prev = now;
      now = "";
    }
     
    cout << prev << endl;
  }
}
      

Measured memory_bytes: 1356
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, l: isize);
    let mut vec_a = Vec::new();
    for i in l..(n as isize) + l {
        vec_a.push(vec![i * i, i]);
    }

    vec_a.sort();

    let mut sum = 0;
    for v in &vec_a {
        sum += v[1] as isize;
    }

    println!("{}", sum - vec_a[0][1]);
}


Measured memory_bytes: 2132
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int q; cin >> q;
	while(q--){
		ll a,b,c,d; cin >> a >> b >> c >> d;
		if(a<b||d-b<0){
			cout << "No" << endl;
			continue;
		}
		if(b<=c){
			cout << "Yes" << endl;
			continue;
		}
		ll g=__gcd(b,d);
		if(b+a%g-g>c){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll h,w,ans=0;
    cin >> h >> w;
    string s[h];
    for (ll i=0;i<h;i++)cin >> s[i];
    for (ll i=0;i<h;i++){
        for (ll j=0;j<w;j++){
            if (s[i][j]=='.')ans++;
        }
    }
    ll dist[h][w];
    for (ll i=0;i<h;i++){
        fill(dist[i],dist[i]+w,-1);
    }
    queue<pair<ll,ll>> que;
    dist[0][0]=1;
    que.push(make_pair(0,0));
    while(!que.empty()){
        ll y=que.front().first,x=que.front().second;
        que.pop();
        for (ll i=0;i<4;i++){
            if (x+dx[i]>=0 and x+dx[i]<w and y+dy[i]>=0 and y+dy[i]<h and s[y+dy[i]][x+dx[i]]=='.' and dist[y+dy[i]][x+dx[i]]==-1){
                dist[y+dy[i]][x+dx[i]]=dist[y][x]+1;
                que.push(make_pair(y+dy[i],x+dx[i]));
            }
        }
    }
    if (dist[h-1][w-1]==-1){
        cout << -1 << endl;
        return 0;
    }
    cout << ans-dist[h-1][w-1] << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Not so Diverse
	var N, K int
	fmt.Scanf("%d %d", &N, &K)

	sc.Split(bufio.ScanWords)
	A := make(map[int]int, N)
	var temp int
	for i := 0; i < N; i++ {
		temp = nextInt()
		A[temp]++
	}

	B := make([]int, 0)
	for _, v := range A {
		B = append(B, v)
	}

	sort.Sort(sort.IntSlice(B))

	var count int = len(A)
	var ans int
	for i := 0; i < N; i++ {
		if count > K {
			count--
			ans += B[i]
		} else {
			fmt.Println(ans)
			break
		}
	}
}


Measured memory_bytes: 17516
n, m = map(int, input().split())
Hs = input().split()
Hs = [int(ele) for ele in Hs]

res = [1 for i in range(n) ]
for i in range(m):
    con = input().split()
    con = [int(ele) for ele in con]
    
    id1 = con[0] - 1
    id2 = con[1] - 1
    
    if res[id1] == 1:
        res[id1] = int(Hs[id2] < Hs[id1])
    if res[id2] ==1:
        res[id2] = int(Hs[id1] < Hs[id2])

print(sum(res))

Measured memory_bytes: 20096
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


class CombTools(object):
    def __init__(self, cap: int, mod: int):
        self.cap = cap
        self.mod = mod
        self.inv = self._calc_inv()
        self.fac = self._calc_fac()
        self.fac_inv = self._calc_fac_inv()

    def _calc_inv(self):
        inv = [0, 1]
        for i in range(2, self.cap+1):
            inv.append((self.mod - (self.mod // i) * inv[self.mod % i]) % self.mod)

        return inv

    def _calc_fac(self):
        fac = [1]
        for i in range(1, self.cap+1):
            fac.append((i * fac[-1]) % self.mod)

        return fac

    def _calc_fac_inv(self):
        fac_inv = [1]
        for i in range(1, self.cap+1):
            fac_inv.append((self.inv[i] * fac_inv[-1]) % self.mod)

        return fac_inv

    def nCr(self, n: int, r: int):
        # validation
        # if r > n:
        #     raise ValueError("n must be larger than r (n={}, r={})".format(n, r))
        # calculation
        return self.fac[n] * self.fac_inv[n-r] * self.fac_inv[r] % self.mod

    def nPr(self, n: int, r: int):
        # validation
        if r > n:
            raise ValueError("n must be larger than r (n={}, r={})".format(n, r))

        # calculation
        return self.fac[n] * self.fac_inv[n-r] % self.mod

    def nHr(self, n: int, r: int):
        return self.nCr(n+r-1, n)


n, k = li()
mod = 10 ** 9 + 7

ct = CombTools(2*n+1, mod)

for i in range(1, k+1):
    if n-k-i+1 < 0:
        print(0)
    else:
        print(ct.nHr(k-i, i) * ct.nHr(n-k-i+1, i+1) % mod)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<ll,ll> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 

void solve(){
    int n;
    cin>>n;
    vector<ll> a(n);
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum^=a[i];
    }
    for(int i=0;i<n;i++){
        cout<<(sum^a[i])<<" ";
    }
    
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0; 
	
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
    
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldb;
    
#define MOD 1000000007
#define MIN 18446744073709551615
#define ff first
#define ss second
#define pub push_back
#define pob pop_back
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define sz(x) (x.size())
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T=1;
	//cin>>T;
	while(T--)
	{
		int n,a=0,t=0,w=0,r=0;
		cin>>n;
		string s,ac="AC",tle="TLE",wa="WA",re="RE";
		for(int i=0;i<n;i++)
		{
			cin>>s;
			if(s==ac)
				a++;
			else if(s==tle)
				t++;
			else if(s==wa)
				w++;
			else if(s==re)
				r++;
		}
		cout<<"AC x "<<a<<"\n";
		cout<<"WA x "<<w<<"\n";
		cout<<"TLE x "<<t<<"\n";
		cout<<"RE x "<<r<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3656
//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 100009
using namespace std;
int main()
{
    ll q,n,t,i,s=0,r,p=0,j,k,l,f;
    cin>>n;
    ll a[n],c[Max]={0};
     f(i,n)
     {cin>>a[i];
     s+=a[i];
     c[a[i]]++;
     }
     r=s;
     cin>>q;
     f(i,q)
     {
         cin>>l>>f;
         s=s+c[l]*f-c[l]*l;
         c[f]+=c[l];
         c[l]=0;
         cout<<s<<endl;
     }
}










Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 2e18
#define h_p 1110111110111;
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
const int N = 2*five;
vector<int> dp[N];
int a[N];
int ans[N];
multiset < int > s;
multiset < int > :: iterator it;
void dfs(int i,int j)
{
       s.insert(a[i]);
       it = s.lower_bound(a[i]);
       it++;
       int xp = -1;
       if(it != s.end())
       {
              xp = *it;
              s.erase(it);
       }
       ans[i] = s.size();
       for(int k : dp[i])
       {
              if(k != j){dfs(k,i);}
       }
       s.erase(s.find(a[i]));
       if(xp != -1){
              s.insert(xp);
       }
}
int main()
{
       int n;
       cin>>n;
       arrin(a,n);
       fri(i,1,n){
              int x,y;
              cin>>x>>y;
              --x;--y;
              dp[x].pb(y);
              dp[y].pb(x);
       }
       dfs(0,0);
       fri(i,0,n){
              cout<<ans[i]<<endl;
       }
}


Measured memory_bytes: 30300
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define pb push_back
#define tp make_tuple
#define srt(a) sort(a.begin(),a.end())
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr(a) printf("%lld\n",a)
#define r0 return 0
#define pi acos(-1)

using namespace std;

int main()
{
    ll n,m,i,j,k,x,y,z,t;

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin>>n;

    m=1e9+7;

    ll a[n+5];

    ll sum=0,ans=0;

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

        ans+=sum*a[i];

        ans%=m;

        sum+=a[i];

        sum%=m;
    }

    cout<<ans<<endl;



}


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

int main() {
  int N, H, W;
  cin >> N >> H >> W;

  cout << (N + 1 - H) * (N + 1 - W) << endl;
  return 0;
}

Measured memory_bytes: 3616
from bisect import bisect

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

cnt_positive = N - bisect(A, 0)
cnt_zero = A.count(0)
cnt_negative = N - cnt_positive - cnt_zero


def is_ok(mid):
    
    if mid < 0:
        cnt_under_mid = 0
        # i=0のときと組み合わせが被らないようにjは1から
        j = 1
        for i in range(cnt_negative):
            a = A[i]
            # A[i]が負なので、A[i] * A[j]は単調減少
            while a * A[j] > mid:
                j += 1
                if j >= N:
                    break
            # あるiについて、A[i] * A[j~N-1] <= mid を満たすペアの数を足す
            cnt_under_mid += (N - j)

            # この時点で積がmid以下になるペアの数がK個以上あれば、そのmidについてそれ以上調べる必要はない
            if cnt_under_mid >= K:
                return True

            # この時点で積がmidのペアの個数がK未満かつ、それ以上mid以下にできる組み合わせがない場合、探索を打ち切る
            if j >= N:
                break

        return False

    # midが0以上の場合、

    else:
        """
        こちらではmidより大きくなる個数を全ペアの個数から引いて考える
        """
        cnt_over_mid = 0
        cnt_duplicate = 0
        r = cnt_negative-1 # A[l]が負のindexで一番右にあるやつ
        for l in range(cnt_negative):
            a = A[l]
            # A[l] * A[r]はrを左に寄せてくるにつれて大きくなる（負 x 負で,右側の負の徐々に絶対値が大きくなるから）
            while a * A[r] <= mid:
                r -= 1
                # lについて、いずれのrをペアにとってもmidを上回らないなら、負の要素についての探索を打ち切る
                if r <= -1:
                    break
            cnt_over_mid += r+1 # 例えばidxでj=2になった時に積がmidを上回るなら、j=0,1,2の三つとの積でmidを超える、みたいな
            # 同じインデックスでペアを作る場合、重複を取り除く
            if r >= l: cnt_duplicate += 1
            # iを右に動かすにつれて、ｊを左に動かさないとmidを超える積ができなくなる（iを右にすると絶対値が小さくなるので、jのほうは絶対値を大きくする必要がある）
            # jをもう動かすことができなくなったら、A[i]が負の場合に、それ以上midを上回るペアを作れないので探索を打ち切る
            if r <= -1:
                break
        
        # Aの要素について、負以外の場合
        cnt_not_positive = cnt_negative + cnt_zero
        l = cnt_not_positive
        # 今度は右から見ていって、対象をlとして、lより右側にある物とペアになればmidを超える、みたいな
        for r in range(N-1, cnt_not_positive-1, -1):
            a = A[r]
            while a * A[l] <= mid:
                # ペアを作って積がmidを超えるまで、lを右にずらしていく
                l += 1
                # これ以上lを右にずらせない場合打ち切り
                if l >= N:
                    break
            # あるrについて、lより右にあるものとペアを作るとmidを超えるので、その個数を足す
            cnt_over_mid += N-l
            # rのペアにrを選んでいる場合は取り除く
            if l <= r:
                cnt_duplicate += 1

            # それ以上lを右にずらせない場合は探索を打ち切る
            if l >= N:
                break
        
        cnt_under_mid = (N*(N-1) // 2) - ((cnt_over_mid - cnt_duplicate) // 2)
        return cnt_under_mid >= K


ok = 10**18 + 1
ng = -1 * 10**18 - 1

while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_ok(mid):
        ok = mid
    else:
        ng = mid

print(ok)

Measured memory_bytes: 88148
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  int n;cin >> n;
  int sum=0;
  int MAX=0;
  rep(i,n){
    int k;cin >> k;
    sum+=k;
    MAX=max(MAX,k);
  }
  cout << sum-MAX/2 << endl;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int LCM(ll a, ll b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vector<ll> t(n);
  rep(i,n) cin>>t[i];
  ll r=1;
  rep(i,n){
    if(r<t[i]) swap(r,t[i]);
    ll tmp=r;
    while(r%t[i]!=0){
      r+=tmp;
    }
  }
  cout<<r<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class b{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    long a = long.Parse(str[0]);
    long v = long.Parse(str[1]);
    str  = Console.ReadLine().Split(' ');
    long b = long.Parse(str[0]);
    long w = long.Parse(str[1]);
    long t = long.Parse(Console.ReadLine());
    long dis = v-w;
    String ans = "NO";
    long disp = (long)Math.Abs(b-a);
    if(dis*t >= disp){
      ans = "YES";
    }
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 17888
l=list(input())
k=int(input())
n=len(l)
if n==1:
    if k%2==0:
        print(k//2)
    else:
        print((k-1)//2)
    exit()
al=[]
su=[]
f=1
for i in range(n-1):
    if l[i]!=l[i+1]:
        al.append(l[i])
        su.append(f)
        f=1
    else:
        f+=1
if l[-2]==l[-1]:
    al.append(l[-1])
    su.append(f)
else:
    al.append(l[-1])
    su.append(1)
    
if len(al)==1:
    j=su[0]*k
    if j%2==0:
        print(j//2)
    else:
        print((j-1)//2)
    exit()

if al[0]!=al[-1]:
    ans=0
    for i in su:
        if i%2==0:
            ans+=i//2
        else:
            ans+=(i-1)//2
    print(k*ans)
else:
    ans=0
    if su[0]%2==0:
        ans+=su[0]//2
    else:
        ans+=(su[0]-1)//2
    tmp=0
    for i in range(len(al)-2):
        if su[i+1]%2==0:
            tmp+=su[i+1]//2
        else:
            tmp+=(su[i+1]-1)//2
    ans+=tmp*k
    j=su[0]+su[-1]
    if j%2==0:
        ans+=(j//2)*(k-1)
    else:
        ans+=((j-1)//2)*(k-1)
    if su[-1]%2==0:
        ans+=su[-1]//2
    else:
        ans+=(su[-1]-1)//2
    print(ans)   


Measured memory_bytes: 3188
//#include<cstdio>
//#include<cstdlib>
#include <iostream>
#include <vector>
#include <queue>
//#include<bitset>
//#include<string>
//#include<stack>
//#include<set>
//#include<unordered_set>
//#include<map>
//#include<unordered_map>
//#include<cstring>
//#include<complex>
//#include<cmath>
//#include<iomanip>
//#include<numeric>
#include <algorithm>
#include <stdio.h>
//#include<list>
//#include<functional>
//#include<cassert>
using namespace std;
#define ll long long int
#define llu unsigned long long int
void pv(vector<ll> arr, ll size)
{

    for (ll i = 0; i < size; i++)
    {
        cout << arr[i] << ' ';
    }
}
void gv(vector<ll> &arr)
{
    ll size = arr.size();
    for (ll i = 0; i < size; i++)
    {
        cin >> arr[i];
    }
}
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s1;
    string s2, ans = "";
    cin >> s1;
    cin >> s2;
    //vector<ll> arr(n);
    ll arr[s1.length() + 1][s2.length() + 1] = {0};
    // string ss[s1.length() + 1][s2.length() + 1];

    for (ll i = 0; i <= s1.length(); i++)
    {
        for (ll j = 0; j <= s2.length(); j++)
        {
            if (i == 0 || j == 0)
            {
                arr[i][j] = 0;
                // ss[i][j] = "";
            }
            else if (s1[i - 1] == s2[j - 1])
            {
                arr[i][j] = 1 + arr[i - 1][j - 1];
                // ss[i][j] = ss[i - 1][j - 1] + s1[i - 1];
                // ans +=
            }
            else
            {
                arr[i][j] = max(arr[i - 1][j], arr[i][j - 1]);
                // if (arr[i - 1][j] >= arr[i][j - 1])
                // {
                //     ss[i][j] = ss[i - 1][j];
                // }
                // else
                // {
                //     ss[i][j] = ss[i][j - 1];
                // }
            }
        }
    }
    // cout << "OK\n";
    ll i = s1.length(), j = s2.length();
    while (i > 0 && j > 0)
    {
        if (s1[i - 1] == s2[j - 1])
        {
            ans = s1[i - 1] + ans;
            i--;
            j--;
        }
        else if (arr[i - 1][j] > arr[i][j - 1])
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 70656
#include <stdio.h>
int main(){
 int x[5]={1,2,3,4,5};
 scanf("%d %d %d %d %d",&x[0],&x[1],&x[2],&x[3],&x[4]);
 for(int i=0;i<5;i++){
  if(x[i]==0)printf("%d",i+1);
 }
 return 0;
}


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

map<string, set<string>> res;
set<string> te;
map<string, int> OK;

set<string> dfs(const string& s) {
	if (OK[s]) {
		return res[s];
	}
	OK[s] = 1;
	auto tmp = res[s];
	for (auto t : tmp) {
		if (te.count(t) == 0) {
			continue;
		}
		res[s].erase(t);
		auto ss = dfs(t);
		res[s].insert(ss.begin(), ss.end());
	}
	return res[s];
}

int main()
{
	int n;
	while (cin >> n, n) {
		string S;
		vector<string> t(n);
		for(int j = 0;j < n;j++) {
			cin >> S;
			int tmp = 0;
			for (int i = 0; i < (int)S.size(); i++) {
				if (S[i] == ':') {
					te.insert(S.substr(0, i));
					t[j] = S.substr(0, i);
					tmp = i + 1;
				}
				else if (S[i] == ',' || S[i] == '.') {
					res[t[j]].insert(S.substr(tmp, i - tmp));
					tmp = i + 1;
				}
			}
		}
		cout << dfs(t[0]).size() << endl;
		res.clear();
		te.clear();
		OK.clear();
	}
	return 0;
}

Measured memory_bytes: 3412
#include<bits/stdc++.h>
using namespace std;
const int maxn = 800 + 7, maxm = 6e5 + 7;
int n, m, to[maxn], ans[maxm];
char s[maxm];

int cal(int x) {
	int rs = 0, t = 1;
	while(x) {
		int y = x % 3;
		if(y) rs += (3 - y) * t;
		t = t * 3; x = x / 3;
	}
	return rs;
}

int main() {
	scanf("%d", &n);
	scanf("%s", s + 1); m = strlen(s + 1);
	int p = n >> 1, d = n - p;
	int r = 1, l = 1;
	for (int i = 1; i <= p; ++i) r = r * 3;
	for (int i = 1; i <= d; ++i) l = l * 3;
	for (int i = 1; i < l; ++i) {
		to[i] = cal(i);
	}
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < l; ++j) ans[j * r + i] = j;
		int o = 0, nowr = i;
		for (int t = 1; t <= m; ++t) {
			if(s[t] == 'S') {
				nowr = to[nowr];
				o ^= 1;
			}
			else {
				if(nowr == r - 1) {
					if(o) for (int j = 0; j < l; ++j) ans[j * r + i] = to[ans[j * r + i]];
					o = 0;
					for (int j = 0; j < l ; ++j) ans[j * r + i] = (ans[j * r + i] + 1) % l;
				}
				nowr = (nowr + 1) % r;
			}
		}
		if(o) for (int j = 0; j < l; ++j) ans[j * r + i] = to[ans[j * r + i]];
		for (int j = 0; j < l; ++j) ans[j * r + i] = ans[j * r + i] * r + nowr;
	}
	for (int i = 0; i < l * r; ++i) printf("%d ", ans[i]);
	printf("\n");
	return 0;
}

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

int main()
{
    int r, g;
    cin >> r >> g;
    cout << 2*g-r << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>

using namespace std;
int main() {
	int n, k; std::cin >> n >> k;
	vector<int> light(n), sum(n, 0);
	for (auto& l : light) cin >> l;
	for (auto t = 0; t < k; ++t) {
		sum.assign(n, 0);
		for (auto i = 0; i < n; ++i) {
			sum[std::max(i - light[i], 0)]++;
			if (i + light[i] + 1 < n) sum[i + light[i] + 1]--;
		}
		for (auto i = 0; i < n; ++i) {
			if (i > 0) sum[i] += sum[i - 1];
			light[i] = sum[i];
		}
		const auto n_count{ std::count(light.begin(), light.end(), n) };
		if (n_count == n) break;
	}
	for (auto i = 0; i < n; ++i) {
		if (i > 0) std::cout << ' ';
		std::cout << light[i];
	}
}

Measured memory_bytes: 4828