akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void)
{
 int a,b;
 scanf("%d",&a);
 scanf("%d",&b);
 if(a < b){
  printf("a < b\n");
 }else if(a > b){
  printf("a > b\n");
 }else{
  printf("a == b\n");
 } 
 return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
map <long long,int> cnt;
long long sum=0;
int main()
{
	int n,x;
	long long ans=0;
	scanf("%d",&n);
	cnt.clear();
	cnt[0]++;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		sum+=x;
		ans+=cnt[sum];
		cnt[sum]++;
	}
	printf("%lld",ans);
	return 0;
}

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

//関数
    
    
    
//main関数
int main() {
    
    
    
    //入力
    long long K;
    int A,B,C;
    cin >>A>>B>>C>>K;
    
    
    
    
    
    
    
    
    
    //計算
    int ans=A-B;
    K%=2;
    ans*=(1-2*K);
    
    
    
    
    
    
    
    
    
    //出力
    cout <<ans<<endl;
}

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

constexpr unsigned long MOD = 998244353;
constexpr unsigned long mx = 1000001;
constexpr unsigned long R = 4294967296, MODinv = 998244351, R2 = 932051910, mask = R - 1, R_bitsize = 32;

constexpr unsigned long montgomery_reduction(unsigned long a){
    return (a + (mask & a * MODinv) * MOD) >> R_bitsize;
}

template<unsigned long maxsize, unsigned long MOD, unsigned long primesize>
class divisor_convolution_coefficients{
    unsigned long sieve[maxsize];
public:
    unsigned long prime[primesize];
    unsigned long coef[maxsize];
    constexpr divisor_convolution_coefficients() : coef(), sieve(), prime(){
        coef[1] = R2;
        for(unsigned long i = 2; i < maxsize; ++i){
            coef[i] = R2 * i % MOD;
            sieve[i] = 1;
        }
        for(unsigned long i = 2, c = 0; i < maxsize; ++i)if(sieve[i]){
                prime[c++] = i;
                for(unsigned long j = i; j < maxsize; j += i){
                    sieve[j] = 0;
                    (coef[j] *= MOD + 1 - i) %= MOD;
                }
            }
    }
};

/*constexpr*/ divisor_convolution_coefficients<mx, MOD, 78498> coef{divisor_convolution_coefficients<mx, MOD, 78498>()};

int main(){
    using namespace std;

    unsigned long N;
    cin >> N;

    unsigned long ans{0};
    unsigned long max_size{0};
    vector<unsigned long> hoge(mx);
    for(unsigned long _ = 0, i; _ < N; ++_){
        cin >> i;
        max_size = max(i, max_size);
        ++hoge[i];
    }
    ++max_size;

    for(const auto& i : coef.prime)for(unsigned long j = max_size / i; j; --j)hoge[j] += hoge[j * i] * i;
    for(auto& i : hoge)i %= MOD;

    ans = MOD - hoge[1];
    for(unsigned long i = 1; i < max_size; ++i)if(hoge[i])ans += montgomery_reduction(montgomery_reduction(hoge[i] * hoge[i]) * coef.coef[i]);
    (ans += (ans & 1) * MOD) >>= 1;
    cout << ans % MOD << endl;

    return 0;
}

Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define pi acos(-1)
#define MOD 998244353
#define MAX 100000
#define inf 1e9+10
#define print(a) cout<< #a <<" --> "<<(a)<<endl
#define Endl endl
#define endk endl
#define Endk endl
#define fileinput freopen("altsub - Copy.txt","r",stdin)
#define fileoutput freopen("max-med.txt","w",stdout)
typedef std::vector<int> vi;
typedef std::vector<vi > vvi;
typedef std::pair<int,int> pii;
typedef long long ll;

 using namespace std;

ll a[MAX+4],b[MAX+4];

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

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

    ll x=(a[n-1]/b[n-1])+1; //print(x);
    x=b[n-1]*x-a[n-1]; //print(x);
    if(a[n-1]%b[n-1]==0) x=0;

    for(int i=n-2;i>=0;i--)
    {
        ll A=a[i]; ll B=b[i]; //if(A==B) continue;
        ll d=(x+A)/B;
        if(B*d-A>=x) x=B*d-A;
        else x=B*(d+1)-A;
    }
    cout<<x<<endl;;

}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int R =10000;
static const int IF = (1<<20);
static const int WH = 0;
static const int GR =1;
static const int BL =2;

int num;
vector<pair<int,int> > ax[R];

void dx(){
  priority_queue<pair<int,int> > Pi;
  int IR[R],i,j,y,x;
  int D[R];

  for(i=0;i<num;i++){
    D[i] = IF;
    IR[i] = WH;
  }

  D[0] = 0;
  Pi.push(make_pair(0,0));
  IR[0] =GR;

  while(!Pi.empty()){
    pair<int,int> F=Pi.top();
    Pi.pop();
    x =F.second;

    IR[x] =BL;

    if(D[x] < F.first * (-1)){
      continue;
    }

    for(j=0;j<ax[x].size();j++){
       y= ax[x][j].first;
       
      if(IR[y] ==BL){
	continue;
      }
      if(D[y] > D[x] + ax[x][j].second){
	 D[y] = D[x] + ax[x][j].second;
	 Pi.push(make_pair(D[y] * (-1),y));
	 IR[y] = GR;
	 }
    }
  }

  for(int i=0;i<num;i++){
    cout << i << " " << (D[i] == IF ? -1 : D[i] ) << endl;
  }
}

int main(){
  int z,x,y,ci,i,j;

  cin >> num;
  for(i=0;i<num;i++){
    cin >> x >> z;

    for(j=0;j<z;j++){
      cin >> y >> ci;
      ax[x].push_back(make_pair(y,ci));
    }
  }
  dx();

  return 0;
}



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

int main() {
  uint32_t N = 0;
  std::cin >> N;

  uint32_t digit_base = 100000000;
  uint32_t digit_sum = 0;
  uint32_t temp_N = N;
  while (digit_base != 0) {
    digit_sum += temp_N / digit_base;
    temp_N = temp_N % digit_base;
    digit_base /= 10;
  }

  std::cout << (N % digit_sum == 0 ? "Yes" : "No") << std::endl;

  return 0;
}

Measured memory_bytes: 256
macro_rules! get_tuple {
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };

    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get_tuple!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, k) = get_tuple!(isize, isize);

    let ans_raw =
        (n * (n + 1) * (n + 2)) / 6
        + (k * (k - 1) * (2 * k - 4 - 3 * n)) / 6
        + n + 2 - k;
    let ans = ans_raw % (1_000_000_007);

    println!("{}", ans);
}


Measured memory_bytes: 2132
n,m = [ int(it) for it in input().split() ]
xli = [ int(it) for it in input().split() ]
yli = [ int(it) for it in input().split() ]

dxli = [0]*( len(xli) -1 )
dyli = [0]*( len(yli) -1 )
for i in range( len(xli) - 1 ):
  dxli[i] = xli[i+1] - xli[i]
for i in range( len(yli) - 1 ):
  dyli[i] = yli[i+1] - yli[i]

MOD = 1000000007
Sx = 0
Sy = 0
for i in range( len(dxli) ):
  Sx += dxli[i] * ( i + 1 ) * ( len(dxli) - i )
  Sx %= MOD
for i in range( len(dyli) ):
  Sy += dyli[i] * ( i + 1 ) * ( len(dyli) - i )
  Sy %= MOD
print ( (Sx*Sy)%MOD )
  

Measured memory_bytes: 83300
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=[[0]*10 for _ in range(10)]
    for i in range(1,n+1):
        i=str(i)
        s=int(i[0]); t=int(i[-1])
        A[s][t]+=1

    ans=0
    for i in range(10):
        for j in range(10):
            ans+=A[i][j]*A[j][i]

    print(ans)
resolve()

Measured memory_bytes: 40300
A['   '];M;B,X,Y;W,J,I;main(){scanf("%d%d",&I,&M);for(;~scanf("%d%d",&X,&Y);){for(B=Y+1,J=1;J*J<=M;J++)I=(X+J-1)/J,W=Y/J+1,A[I]++,A[W<B?W:B]--,B=I;for(I=1;I<B;I++)if((X-1)/I<Y/I)A[I]++,A[I+1]--;}for(I=1;I<=M;I++){A[I]+=A[I-1];printf("%d\n",A[I]);}}

Measured memory_bytes: 1280
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T>
inline void chmax(T &a, const T &b) {
    if ((a) < (b)) (a) = (b);
}
template <class T>
inline void chmin(T &a, const T &b) {
    if ((a) > (b)) (a) = (b);
}

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x)    \
    sort(all(x)); \
    x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
    }
} fast;
void check_input() {
    assert(cin.eof() == 0);
    int tmp;
    cin >> tmp;
    assert(cin.eof() == 1);
}

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;


int solve() {
    ll h,w;cin>>h>>w;
    vec<string> s(h);
    rep(i, h){
        cin>>s[i];
    }

    int dx[]={1, -1, 0, 0};
    int dy[]={0, 0, 1, -1};
    rep(i, h)rep(j, w){
        if (s[i][j] == '#') {
            bool valid = false;
            rep(k, 4){
                int ni = i + dx[k];
                int nj = j + dy[k];
                if (is_in(ni, 0, h) && is_in(nj, 0, w)){
                    if (s[ni][nj]=='#') valid = true;
                }
            }
            if (!valid) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    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();
    List<Integer> s = new ArrayList<>();
    for(int i = 0; i < n; i++) {
      s.add(sc.nextInt());
    }
    int q = sc.nextInt();
    List<Integer> t = new ArrayList<>();
    for(int i = 0; i < q; i++) {
      t.add(sc.nextInt());
    }
    int count = 0;
    for(int i = 0; i < t.size(); i++) {
      for(int e : s) {
        if(t.get(i) == e) {
          count++;
          break;
        }
      }
    }
    System.out.println(count);
  }
}



Measured memory_bytes: 40456
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];
        public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] height = new int[n];
        int[] ary = new int[m];
        int[] bry = new int[m];
        for(int i = 0;i < n;i++){
            height[i] = sc.nextInt();
        }
        node = new List[n];
        for(int i = 0;i < n;i++){
            node[i] = new ArrayList<Integer>();
        }
        for(int i = 0;i < m;i++){
            ary[i]= sc.nextInt();
            bry[i] = sc.nextInt();
            add(ary[i]-1, bry[i]-1);
        }
        //一番高い展望台or辿り着ける展望台がない:よい
        int ans = 0;       
        for(int i = 0;i < n;i++){
            if(node[i].size()==0){
                ans++;
                continue;
            }
            for(int j = 0;j < node[i].size();j++){
                if(height[i]<=height[(int)node[i].get(j)]){
                    ans--;
                    break;
                }
            }
            ans++;
        } 
        System.out.println(ans);
    }
    public static List[] node;
    static void add(int i,int j){
        if(i==j)return;
        node[i].add(j);
        node[j].add(i);
    }
    
}


Measured memory_bytes: 74148
<?php
fscanf(STDIN, "%d%d", $H, $W);
for($y = 0; $y < $H; $y++){
    fscanf(STDIN, "%s", $str);
    $map[$y] = str_split($str);
    for($x = 0; $x < $W; $x++){
        if($map[$y][$x] == "#"){
            $list[$y][$x] = 1;
        }
    }
}
$count = 0;
while($list){
    $nextList = [];
    foreach($list as $y => $xs)foreach($xs as $x => $_){
        if($x){
            if($map[$y][$x-1] == "."){
                $map[$y][$x-1] = "#";
                $nextList[$y][$x-1] = 1;
            }
        }
        if($y){
            if($map[$y-1][$x] == "."){
                $map[$y-1][$x] = "#";
                $nextList[$y-1][$x] = 1;
            }
        }
        if($x < $W-1){
            if($map[$y][$x+1] == "."){
                $map[$y][$x+1] = "#";
                $nextList[$y][$x+1] = 1;
            }
        }
        if($y < $H-1){
            if($map[$y+1][$x] == "."){
                $map[$y+1][$x] = "#";
                $nextList[$y+1][$x] = 1;
            }
        }
    }
    $list = $nextList;
    if($list)$count++;
}
echo $count;


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

int main(void){
    int A , B , C , X;
    cin >> A >> B >> C >> X;
    int num = 0;
    for(int i =0; i <= A ; i++){
        for(int j =0; j <= B ; j++){
            for(int k =0; k <= C; k++){
                if(0 == (X - i*500 - j*100 - k*50)){
                 //   cout << i << " " << j << " "<< k << endl;
                    num++;     
                }
            }
        }
    }
    cout << num;

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	exist := make(map[int]bool)
	d := make([]int, n)
	set := make([]int, 0)
	for i := 0; i < n; i++ {
		fmt.Scan(&d[i])
		if _, ok := exist[d[i]]; !ok {
			exist[d[i]] = true
			set = append(set, d[i])
		}
	}
	fmt.Println(len(set))
}


Measured memory_bytes: 512
import itertools
n = int(input())
d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(n):
  s = input()
  if s[0] in d:
    d[s[0]] += 1
ans = 0
for v in itertools.combinations(d, 3):
    ans += d[v[0]] * d[v[1]] * d[v[2]]
print(ans)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define ll              long long int
#define int             int64_t
#define ff              first
#define ss              second
#define pb              push_back
#define mpair           make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define sbits(x)      __builtin_popcountll(x)
#define zbits(x)      __builtin_popcountlliltin_ctzll(x)
#define w(t)            int t;cin>>t;while(t--)
#define uset            unordered_set
#define en              cout<<endl
using namespace std;
void fast(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);}
int max2(int a,int b){ if(a>b) return a;return b;}
int min2(int a,int b){ if(a<b)return a;return b;}
int max3(int a,int b,int c){ return max2(a,max2(b,c));}
int min3(int a,int b,int c){ return min2(a,min2(b,c));}
void system_output(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
}
void solve(){
      int k,a,b;
      cin>>k>>a>>b;
      if(a== b && a%k!=0){
        cout<<"NG"<<endl;
        return;
      }
      if((b-a)/k >=1){
         cout<<"OK"<<endl;
         return;
      }
      //cout<<(b%k)<<" "<<(a%k)<<endl;
      if((b%k <=a%k) || (b%k==0) || (a%k ==0))
        cout<<"OK"<<endl;
        else
        cout<<"NG"<<endl;    
}
signed main(void)
{
      fast();
      //w(t)
      solve();

}


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#define N 100005
using namespace std;
int n,a[N],ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n ;i++)
		scanf("%d",&a[i]);
	a[n+1]=2e9;
	int res=0;
	for(int i=n;i;i--){
		if(a[i]>=a[i+1]) res++;
		else res=0;
		ans=max(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <cmath>
#include <algorithm>
#include <array>

int main(int argc, char *argv[]){
    int N;
    long long K;
    std::cin >> N >> K;
    std::array<long long,(1<<17)> A;
    for(int i=0; i<N; ++i){
        std::cin >> A[i];
    }

    std::array<long long, 2> dp;
    for(int j=0; j<2; ++j){
        dp[j] = 0LL;
    }
    long long xor0, xor1;
    long long tmp0, tmp1;
    bool isStarted = false;
    for(int i=0; i<61; ++i){
        xor0 = 0LL; xor1 = 0LL;
        for(int j=0; j<N; ++j){
            xor0 += ((A[j]>>(60-i))&1LL)^0LL; 
            xor1 += ((A[j]>>(60-i))&1LL)^1LL; 
        }
        xor0 <<= 60-i; xor1 <<= 60-i;
        if(((K>>(60-i))&1LL) == 1LL){
            if(isStarted){
                tmp0 = dp[0] + xor0;
                tmp1 = dp[1] + std::max(xor0, xor1);
                dp[0] += xor1;
                dp[1] = std::max(tmp0,tmp1);            
            }else{
                isStarted = true;
                dp[0] += xor1;
                dp[1] += xor0;
            }
        }else{
            dp[0] += xor0;
            if(isStarted){
                dp[1] += std::max(xor0, xor1);
            }else{
                continue;
            }
        }
    }

    std::cout << std::max(dp[0],dp[1]) << std::endl;

    return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 998244353;

const int MAXN = 3e2 + 5;

int v[MAXN][MAXN];

void solve(){
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, 0, n) {
		REP(j, 0, m) {
			scanf("%d", &v[i][j]);
		}
	}
	int ind = 0;
	REP(k, 0, m) {
		REP(i, ind, n) {
			if (v[i][k] == 1) {
				REP(j, k, m) {
					swap(v[i][j], v[ind][j]);
				}
				break;
			}
		}
		if (v[ind][k] == 0) {
			continue;
		}
		REP(i, ind + 1, n) {
			if (v[i][k]) {
				v[i][k] = 0;
				REP(j, k + 1, m) {
					v[i][j] ^= v[ind][j];
				}
			}
		}
		ind++;
	}
	ll v1 = 1ll, v2 = 1ll;
	REP(i, 0, n + m - 1) {
		v1 = (v1 * 2) % MOD;
	}
	REP(i, 0, n + m - ind - 1) {
		v2 = (v2 * 2) % MOD;
	}
	ll ans = (v1 + MOD - v2) % MOD;
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 640
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = read_line () |> split_string ~pattern:" " |> List.map int_of_string

let rec range res acc = match res, acc with
  | [], _ -> failwith "program error"
  | res, [] -> res
  | (l, r) :: _, x :: xs -> range (((l + 1) / 2 + x, r + x) :: res) xs
let range = function
  | [] -> failwith "program error"
  | x :: xs -> range [(x, x)] xs

let rec build sum prev rs ns = match rs, ns with
  | _, [] -> sum
  | (l, r) :: rs, n :: ns -> let t = min (prev * 2) r in build (sum + t) (t - n) rs ns
  | _ -> failwith "program error"

let () =
  let acc = range (List.rev a) in
  match acc, a with
    | x :: xs, n :: ns -> Printf.printf "%d\n" @@ if fst x = 1 then build 1 1 xs ns else -1
    | _ -> failwith "program error"

Measured memory_bytes: 22224
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readInt()
    val a = readListOfLong().toMutableList()
    val b = readListOfLong()

    var cnt = 0L
    for(i in 0 until n) {
        val city1 = a[i]
        val city2 = a[i+1]
        val braver = b[i]
        a[i] = if(city1 <= braver) 0L else city1 - braver
        a[i+1] = if(city1 <= braver) {
            if(braver - city1 >= city2) 0L else city2 - (braver - city1)
        } else city2
        cnt += (city1 - a[i]) + (city2 - a[i+1])
        //println(a)
    }
    println(cnt)
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
    }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    (a * b) / gcd(a, b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 80308
class UnionFind
  def initialize(n)
    @n = n
    @par = Array.new(@n, -1)
  end
  def find(x)
    @par[x] < 0 ? x : @par[x] = find(@par[x])
  end
  def union(a, b)
    pa, pb = find(a), find(b)
    return if pa == pb
    if pa < pb then
      @par[pa] += @par[pb]
      @par[pb] = pa
    else
      @par[pb] += @par[pa]
      @par[pa] = pb
    end
  end
  def max_size
    -@par.min
  end
  def show
    p @par
  end
end

N, M = gets.chomp.split(" ").map(&:to_i)
uf = UnionFind.new(N)
(0...M).map{
  a, b = gets.chomp.split(" ").map(&:to_i)
  uf.union(a-1, b-1)
}

puts uf.max_size


Measured memory_bytes: 17804
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

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

int dfs(int dir, int x, int y, const vector<string>& grid, vector<vint>& memo) {
    // cerr << "(x, y): " << x << " " << y << endl;
    if(memo[y][x] != -1) return memo[y][x];
    int tx = x + dx[dir];
    int ty = y + dy[dir];
    if(grid[ty][tx] == '#') return 0;
    return memo[y][x] = dfs(dir, tx, ty, grid, memo) + 1;
}

int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h+2);
    rep(y, h) {
        cin >> s[y+1];
        s[y+1] = "#" + s[y+1] + "#";
    }
    s[0] = s[h+1] = string(w+2, '#');
    // cerr << "s: " << endl; rep(y, h+2) cerr << s[y] << endl;
    vector<vint> memo[4];
    rep(i, 4) memo[i] = vector<vint>(h+2, vint(w+2, -1));
    int ans = 0;
    FOR(y, 1, h+1) {
        FOR(x, 1, w+1) {
            if(s[y][x] == '#') continue;
            int sum = 1;
            rep(dir, 4) {
                sum += dfs(dir, x, y, s, memo[dir]);
            }
            chmax(ans, sum);
            // dump(ans);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 71040
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 

int main()
{
	multiset<int>a;
	int n,m,i,s=0,t;
	cin>>n>>m;
	while(n--)
	{
		cin>>t;
		a.insert(t);
	}
	//for(multiset<int>::iterator it=a.begin();it!=a.end();it++)cout<<*it<<' ';cout<<endl;
	for(i=0;i<m;i++)s+=*a.begin(),a.erase(a.begin());
	cout<<s;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	//freopen("data","r",stdin);
	long long n,a,b;
	long long ret=0;
	cin>>n>>a>>b;
	std::vector<int> v;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		v.push_back(t);
		if(i==0)continue;
		else{
			ret=ret+min((v[i]-v[i-1])*a,b);
		}
	}
	cout<<ret<<endl;
	return 0;
}

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

struct Problem {
public:

	void Solve() {
		string S; cin >> S;
		UL N = S.size();
		rep(i, N) if (S[i] == '?') S[i] = 'D';
		cout << S << endl;
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}


Measured memory_bytes: 3756
#!/usr/bin/perl
#abc087_c.pl
#Sun Jan 28 20:20:21 2018
#

use warnings;
use strict;

my $temp = <STDIN>;
chomp $temp;
my $n = $temp;

my $temp1 = <STDIN>;
chomp $temp1;
my @a1 = split(" ",$temp1);

my $temp2 = <STDIN>;
chomp $temp2;
my @a2 = split(" ",$temp2);

my @a1accum;
$a1accum[0] = $a1[0];
my $num = 1;

while ($num<=$#a1){
	push (@a1accum, $a1[$num]+$a1accum[$num-1]);
	$num++;
}

my @a2accum;
my $a2total = 0;
foreach (@a2){
	$a2total = $a2total + $_;
}

$a2accum[0] = $a2total;
$num = 1;

while ($num<=$#a2){
	push (@a2accum, $a2accum[$num-1]-$a2[$num-1]);
	$num++;
}

$num = 0;

my $ans = 0;

while ($num < $n){
	my $total = $a1accum[$num]+$a2accum[$num];
	if ($total > $ans){
		$ans = $total;
	}
	$num++;
}

print $ans,"\n";

Measured memory_bytes: 640
#include<stdio.h>

int n;

int main(){
//	freopen("in6.txt","r",stdin);
	scanf("%d", &n);
	int ans = 0, val;
	for(int i=0;i<n;i++){
		scanf("%d", &val);
		ans += val-1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> h(N+K);
	vector<int> cost(N+K,999999999);
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	cost[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int n = 1; n <= K; n++) {
			cost[i + n] = min(cost[i + n], cost[i] + abs(h[i] - h[i + n]));
		}
	}
	cout << cost[N-1] << endl;
}

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

class dice {
public:
	int f[6];
	dice() {}
	void roll(int i, int j, int k, int l) {
		int tmp;
		tmp = f[i];
		f[i] = f[j];
		f[j] = f[k];
		f[k] = f[l];
		f[l] = tmp;
	}
	void roll_z() { roll(1, 2, 4, 3); }
	void roll_y() { roll(0, 2, 5, 3); }
	void roll_x() { roll(0, 1, 5, 4); }

	void move(char ch) {
		if (ch == 'E') {
			for (int i = 0; i < 3; i++) {
				roll_y();
			}
		}
		if (ch == 'W') {
			roll_y();
		}
		if (ch == 'N') {
			roll_x();
		}
		if (ch == 'S') {
			for (int i = 0; i < 3; i++) {
				roll_x();
			}
		}

	}
	int top() {
		return f[0];
	}
};

int main() {
	dice d2;
	for (int i = 0; i < 6; i++) {
		cin >> d2.f[i];
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
        int a, b;
		cin >> a >> b;
		if (d2.f[0] != a) { 
			int i = 0;
			while (i < 4) {
				if (d2.f[0] == a) break;
				d2.roll_x();
				i++;
			}
			int k = 0;
			while (k < 4) {
				if (d2.f[0] == a) break;
				d2.roll_y();
				k++;
			}
		}
		int j = 0;
		if (d2.f[1] != b) {
			while (j < 4) {
				if (d2.f[1] == b) break;
				d2.roll_z();
				j++;
			}
		}
		cout << d2.f[2] << endl;
	}
	return 0;
}





Measured memory_bytes: 3088
S = input()

ans = 'WA'

if S[0] == 'A' and S[2:-1].count('C') == 1:
    a = S[2:-1].replace('C','c')
    if a.islower() and S[-1].islower() and S[1].islower():
        ans='AC'
        
print(ans)
    


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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

char s[100005];

int k;

int main()
{
	scanf("%s", s);
	scanf("%d", &k);
	int n = strlen(s);
	for (int i = 0; i < n; i++) if (s[i] != 'a')
	{
		int need = 'z' - s[i] + 1;
		if (need <= k)
		{
			s[i] = 'a';
			k -= need;
		}
	}
	s[n - 1] = 'a' + (s[n - 1] - 'a' + k) % 26;
	printf("%s\n", s);
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

    ll A, B; cin >> A >> B;
    if (A % 2 == B % 2) {
        cout << (A+B) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

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


void solve(long long n, std::vector<long long> a){
    deque<int> b;
    for(int i = 0; i < (int)n; ++i){
        if(i % 2 == 0) b.push_back((int)a[i]);
        else b.push_front((int)a[i]);
    }
    if(n % 2 != 0) reverse(b.begin(), b.end());
    for(int i = 0; i < (int)n; ++i){
        if(i) cout << " ";
        cout << b[i];
    }
    cout << endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> a(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&a[i]);
    }
    solve(n, std::move(a));
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k;
    string s;
    cin >> k >> s;
    if (s.size() > k) {
        s = s.substr(0,k).append(3,'.');
    }
    cout << s;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>

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

    int n;

    std::cin >> n;
    
    for (; n--;) {
        int h, m;
        char tmp;
        std::cin >> h >> tmp >> m;

        double angle_h, angle_m, diff;

        angle_h = 30. * h + 0.5 * m;
        angle_m = 6. * m;

        diff = std::abs(angle_h - angle_m);

        if (diff > 180.) {
            diff = 360. - diff;
        }

        if (diff < 30.) {
            std::cout << "alert" << std::endl;
        }
        else if (diff < 90.) {
            std::cout << "warning" << std::endl;
        }
        else {
            std::cout << "safe" << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

double r;

int main(void)
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> r;
	printf("%.11f\n", 2 * r * 3.14159265358979);
	
	return 0;
}

Measured memory_bytes: 3784
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
int ans[2345];
int main(){
    std::ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll i,n=s.length(),lef,val;
    rep(i,n){
    	ans[s[i]]++;
    }
    lef=n-1;
    val=1;
    rep(i,n){
    	ans[s[i]]--;
    	val+=lef-ans[s[i]];
    	lef--;
    }
    cout<<val<<endl;


    return 0;      

}



Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define N 1000005
int n,m,ans[N];
int main()
{
	scanf("%d %d",&n,&m);
	if(n&1) for(int i=1;i<=m;++i) printf("%d %d\n",i,n-i);
	else
	{
		for(int i=1;i<=((n>>1)>>1);++i) ans[i]=n-i+1;
		for(int i=((n>>1)>>1)+1;i<=(n>>1);++i) ans[i]=n-i;
		for(int i=1;i<=m;++i) printf("%d %d\n",i,ans[i]);
	}return 0;
}

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

using namespace std;

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

	if (A > 8 || B > 8) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
}

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

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0])
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


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

int main() {
    int N;
    cin>>N;
    int ans = 0;
    for(int i=1;i<=N;++i){
        if(i%2==0)continue;
        int tmp = 0;
        for(int j=1;j<=i;++j){
            if(i%j==0)tmp++;
        }
        if(tmp==8){
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

int main()
{
	int h[10];
	for (int i = 0; i < 10; ++i) cin >> h[i];
	sort(h, h+10);
	
	cout << h[9] << endl << h[8] << endl << h[7] << endl;
	
	return 0;
	
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B;
    cin >> A >> B;
    if(A > 12){
        cout << B << endl;
    }
    else if (A >= 6){
        cout << B / 2 << endl;
    }
    else{
        cout << 0 << endl;        
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int asc(const void* a, const void* b)
{
	if (*(int*)a > * (int*)b)return -1;
	if (*(int*)a < *(int*)b)return 1;
	return 0;
}
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i;
	int a[100005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	qsort(a, n, sizeof(int), asc);
	int min, mid, max;
	while (m > 0)
	{
		if (a[0] == 0)
			break;
		a[0] /= 2;
		m--;
		min = 1;
		max = n;
		while (max - min > 1)
		{
			mid = (max + min) / 2;
			if (a[mid] > a[0])
				min = mid;
			else
				max = mid;
		}
		if (a[max] > a[0])
			max++;
		if (max - 1 <= m)
		{
			m -= max - 1;
			for (i = 1; i < max; i++)
				a[i] /= 2;
			qsort(a, n, sizeof(int), asc);
		}
		else
		{
			i = 1;
			while (m > 0)
			{
				a[i] /= 2;
				m--;
				i++;
			}
		}
	}
	long long int ans = 0;
	for (i = 0; i < n; i++)
		ans += (long long int)a[i];
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

typedef long long ll;

int n, ac = 0, tle = 0, re = 0, wa = 0;

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

    cin >> n;
    string s;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        if (s[0] == 'A' && s[1] == 'C'){
            ac++;
        }
        if (s[0] == 'W' && s[1] == 'A'){
            wa++;
        }
        if (s[0] == 'T' && s[1] == 'L' && s[2] == 'E'){
            tle++;
        }
        if (s[0] == 'R' && s[1] == 'E'){
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
 
    return 0;
}


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

int main(){
  int a;
  rep(i,5){
    cin >> a;
    if(a==0){
      cout << i+1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 3544
from operator import itemgetter

a=list(map(int,input().split()))
n=4*int(input())
p=[]
for i in range(4):
    p.append([2**i,a[i]*4,(a[i]*4)/2**i])


p=sorted(p,key=itemgetter(2))

ans=0

for i in range(4):
    t=n//p[i][0]
    ans += t*p[i][1]
    n -= t*p[i][0]

print(ans//4)


    


Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main()
{
	int H,W;
	int H2;
	cin >> H >> W;
	H2 = H*2;
	char c[100][100];
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			cin >> c[i][j];
		}
	}
	char c2[200][100];
	for(int i=0;i<H2;i++)
	{
		for(int j=0;j<W;j++)
		{
			c2[i][j]=c[i/2][j];
		}
	}
	for(int i=0;i<H2;i++)
	{
		for(int j=0;j<W;j++)
		{
			cout << c2[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main (){

let mut _ab : f64;
let mut _bc : f64;
let mut _ca : f64;

input! {
    ab : f64,
    bc : f64,
    ca : f64,

}

let ans : f64 = (bc/2.0)*ab ; 
//let ans_1 : i128 = ((bc/2)+1/2)*ab ; 
println!("{}",ans);
}

Measured memory_bytes: 2208
using System;

namespace Getting_Started
{
    class Maximum_Profit
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var R = new int[n];
            for (int i = 0; i < R.Length; i++)
                R[i] = int.Parse(Console.ReadLine());

            var min = R[0];
            var max = -1000000000;

            for (int i = 1; i < R.Length; i++)
            {
                if (R[i] - min > max) max = R[i] - min;
                if (R[i] < min) min = R[i];
            }

            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 10912
use proconio::fastout;
use whiteread::parse_line;
#[allow(unused_mut)]
#[fastout]
fn main() {
    //input
    let (n, m): (usize, usize) = parse_line().unwrap();
    let mut switches: Vec<Vec<usize>> = Vec::new();
    for _ in 0..m {
        let input: Vec<usize> = parse_line().unwrap();
        switches.push(input);
    }
    let p: Vec<usize> = parse_line().unwrap();

    let mut res = 0;
    for bit in 0..(1 << n) {
        let mut can = true;

        for i in 0..m {
            //num of bulbs turned on
            let mut tmp = 0;

            for v in switches[i].iter().skip(1) {
                if bit & (1 << (v - 1)) != 0 {
                    tmp += 1;
                }
            }

            if tmp % 2 != p[i] {
                can = false;
            }
        }

        if can {
            res += 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2176
N = int(input())
X = [[0] * N for _ in range(N)]
for i in range(1, N):
    X[i][:i] = [int(a) for a in input()]
for i in range(N):
    for j in range(i+1, N):
        X[i][j] = X[j][i]^1

A = [1<<i for i in range(N)]
B = [1<<i for i in range(N)]
for i in range(N):
    for j in range(i):
        if i and B[i-1] >> j & 1 and X[i][j]: A[i] |= A[j]
    for j in range(i):
        if A[i] >> j+1 & 1 and X[j][i]: B[i] |= B[j]

print(sum([(A[i] & 1) * (B[N-1]>>i & 1) for i in range(N)]))

Measured memory_bytes: 86364
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;

ll a[maxn];
int main(){
	ll n,m;
	cin>>n>>m;
	ll sum=0;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	ll res=0;
	for(int i=1;i<=n;i++){
		if(a[i]*4*m>=sum) res++;
	}
	if(res>=m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = int(input())
p = [int(x) for x in input().split()]
ans = 0
for i in range(n-2):
  if p[i]<p[i+1] and p[i+1]<p[i+2]:
    ans += 1
  elif p[i]>p[i+1] and p[i+1]>p[i+2]:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;++i)

const int N=2005;
const int P=924844033;
int n,k,a[N],fac[N];
long long f[N][N][2][2];
bool vis[N];

int main() {
    scanf("%d%d",&n,&k);
    fac[0]=1;
    FOR(i,1,n) fac[i]=1LL*fac[i-1]*i%P;
    int tot=0;
    FOR(i,1,n) if(!vis[i]) for(int j=i;j<=n;j+=k) vis[j]=1,a[++tot]=j;
    f[0][0][0][0]=1;
    a[0]=-(1<<30);
    FOR(i,1,n) {
        f[i][0][0][0]=1;
        FOR(j,1,i) {
            f[i][j][0][0]=(f[i-1][j][1][0]+f[i-1][j][0][0]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][0])%P;
            f[i][j][0][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][1][0]+f[i-1][j-1][0][0])%P;
            f[i][j][1][0]=(f[i-1][j][0][1]+f[i-1][j][1][1]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][1])%P;
            f[i][j][1][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][0][1]+f[i-1][j-1][1][1])%P;
        }
    }
    int ans=0;
    FOR(i,0,n) {
        int sum=(f[n][i][0][0]+f[n][i][0][1]+f[n][i][1][0]+f[n][i][1][1])%P;
        if(i&1) (ans+=P-1LL*sum*fac[n-i]%P)%=P;
        else (ans+=1LL*sum*fac[n-i]%P)%=P;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 123648
#include <stdio.h>
#include <string.h>

int steps[10000];

void charSwap(char* a, char* b)
{
    char tmp = *a;
    *a = *b;
    *b = tmp;
}

void reverse(char* str)
{
    int i;
    int len = (int)strlen(str);
    for (i = 0; i < len / 2; i++) {
        charSwap(str + i, str + len - 1 - i);
    }
}

void mySort(char* N)
{
    int i, j;
    int len = (int)strlen(N);
    for (i = 0; i < len; i++) {
        for (j = i; j < len; j++) {
            if (N[j] < N[i]) {
                charSwap(N + j, N + i);
            }
        }
    }
}

int countStep(int n)
{
    char strN[5];
    int max, min, diff;

    if (steps[n] != -1) return steps[n];

    if (n == 6174) return (0);

    sprintf(strN, "%04d", n);

    mySort(strN);
    sscanf(strN, "%d", &min);

    reverse(strN);
    sscanf(strN, "%d", &max);

    diff = max - min;
    return (steps[n] = countStep(diff) + 1);
}

int main(void)
{
    int i;
    int N;

    for (i = 0; i < 10000; i++) {
        steps[i] = -1;
    }

    while (1) {
        scanf("%d", &N);
        if (N == 0) break;
        if (N % 1111 == 0) {
            printf("NA\n");
            continue;
        }
        printf("%d\n", countStep(N));
    }
    return (0);
}

Measured memory_bytes: 668
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  rep(i, 0, h) cin >> v[i];

  vector<vector<int>> acch(h, vector<int>(w, 0));
  vector<vector<int>> accw = acch;

  rep(i, 0, h) {
    int now = 0;
    rep(j, 0, w) {
      if (v[i][j] == '#') {
        now = 0;
      } else {
        now++;
        accw[i][j] = now;
      }
    }
    now = 0;
    repr(j, 0, w) {
      if (v[i][j] == '#') {
        now = 0;
      } else {
        now++;
        accw[i][j] += now - 1;
      }
    }
  }

  rep(i, 0, w) {
    int now = 0;
    rep(j, 0, h) {
      if (v[j][i] == '#') {
        now = 0;
      } else {
        now++;
        acch[j][i] = now;
      }
    }
    now = 0;
    repr(j, 0, h) {
      if (v[j][i] == '#') {
        now = 0;
      } else {
        now++;
        acch[j][i] += now - 1;
      }
    }
  }

  int ans = 0;
  rep(i, 0, h) {
    rep(j, 0, w) { chmax(ans, acch[i][j] + accw[i][j]); }
  }

  cout << ans - 1 << endl;
}


Measured memory_bytes: 38856
#include <stdio.h>
#include <string.h>

int main(){
  int l, i, r;
  char n[1024];
  while(scanf("%s", n) && n[0] != '0'){
    l = strlen(n);
    for(r = i = 0; i < l; i++) r += n[i];
    printf("%d\n", r - l * '0');
  }
  return 0;
}

Measured memory_bytes: 536
input_s =[input() for i in range(3)]
color_1, color_2 = list(input_s[0].split())
a, b = list(map(int,input_s[1].split()))
color = input_s[2]
if  color == color_1:
    print(a-1, " ", b)
else:
    print(a, " ", b-1)

Measured memory_bytes: 38384
N = gets.to_i
A = []
B = []
N.times do 
    a,b = gets.split.map &:to_i 
    A << a
    B << b
end
A.sort!
B.sort!

if N%2==1 then
    ma = A[(N+1)/2-1]
    mb = B[(N+1)/2-1]
else
    ma = A[N/2-1] + A[(N/2)]
    mb = B[N/2-1] + B[(N/2)]
end

puts mb-ma+1

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

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

Measured memory_bytes: 3584