akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX 2000000000
int count=0,n;
void merge(int* A,int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int i,j,k;
  int L[n1+1];
  int R[n2+1];
  for(i = 0;i <n1;i++){
    L[i] = A[left + i];
  }
  for(i = 0;i < n2;i++){
    R[i] = A[mid + i];
  }
  L[n1] =MAX;
  R[n2] =MAX;
  i = 0;
  j = 0;
  for(k = left;k <right;k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{ 
      A[k] = R[j];
      j = j + 1;
    }
  }
}

  void mergeSort(int* A,int left,int right){
    int mid,i;
    if(left+1 < right){
	mid = (left + right)/2;
      mergeSort(A, left, mid);
      mergeSort(A, mid, right);
      merge(A, left, mid, right);
    }
}

int main(){
  int *s;
  int i;
  scanf("%d",&n);
  s=(int*)malloc(sizeof(int) * n);
  for(i=0;i < n;i++){
    scanf("%d",&s[i]);
  }
  mergeSort(s,0,n);

  for(i=0;i < n-1;i++){
    printf("%d ",s[i]);
  }
  printf("%d\n",s[i]);
  printf("%d\n",count);

  return 0;
}



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

using namespace std;

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

  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (auto &g : grid) cin >> g;
  int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
  int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
  for (int i = 0; i < h; ++i) 
    for (int j= 0; j < w; ++j) {
      if (grid[i][j] == '.') {
        int sum = 0;
        for (int k = 0; k < 8; ++k) {
          int ip = i + dx[k];
          int jp = j + dy[k];
          if (ip >= 0 && ip < h && jp >= 0 && jp < w) 
            if (grid[ip][jp] == '#') sum++;
        }
        grid[i][j] = (char)('0'+sum);
      }
    }

  for (auto &g : grid)
    cout << g << endl;

  return 0;
}



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

long long solve(vector<vector<int>> task){
		int N=task.size();
		int dp[N][3];
		dp[0][0]=task[0][0];
		dp[0][1]=task[0][1];
		dp[0][2]=task[0][2];
		for(int i=1;i<N;i++)
		{
			dp[i][0]=task[i][0]+max(dp[i-1][1],dp[i-1][2]);
			dp[i][1]=task[i][1]+max(dp[i-1][0],dp[i-1][2]);
			dp[i][2]=task[i][2]+max(dp[i-1][0],dp[i-1][1]);
		}
		return max(max(dp[N-1][0],dp[N-1][1]),dp[N-1][2]);
}

int main(){
  int N;
  cin>>N;
  int t;
  vector<vector<int>> task;
  for(int i=0;i<N;i++){
	  vector<int> h;
    for(int j=0;j<3;j++){
      cin>>t;
	  h.push_back(t);
    }
	task.push_back(h);
  }
  cout<<solve(task)<<endl;
  return 0;
}

Measured memory_bytes: 13104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    bool first = false;
    rep(i,n){
        ll a; cin>>a;
        if(a%2==1)first = true;
    }
    cout<<(first?"first":"second")<<endl;
    return 0;
}

Measured memory_bytes: 764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            if (s.contains("7"))
                out.println("Yes");
            else
                out.println("No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 25640
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)



//cout<<fixed<<setprecision(10);
int main(){
    ll n;
    cin>>n;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    vector<ll> cnt;
    ll m=n;
    for(ll i=2;i*i<=m && n>1;i++){
        if(n%i==0){
            ll tmp=0;
            while(n%i==0){
                tmp++;
                n/=i;
            }
            cnt.push_back(tmp);
        }
    }
    ll ans=0;
    if(n!=1) ans++;
    n=cnt.size();
    
    rep(i,n){
        ll k=0;
        while(((k+1)*(k+2))/2 <= cnt[i]){
            k++;
        }
        ans+=k;
    }

    cout<<ans<<endl;
    

    return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <random>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(n) while(n--)
#define loop while(true)
#define YN(f) f?cout<<"YES"<<endl:cout<<"NO"<<endl;
#define yn(f) f?cout<<"Yes"<<endl:cout<<"No"<<endl;

int ans;
int cnt;

signed main(){
	string s;cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='W'){
			ans+=i-cnt;
			cnt++;
		}
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <set>
#include <map>
#include <cstdio>
using namespace std;
using ll = long long;


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


int dat[200007];

int main() {

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

    //rep(i, N)cin >>dat[i];

    cin >> N;
    int count = 0;
    rep1(i, N) {
        count += (N-1) / i;
    }
    cout << count << endl;
    return 0;
}

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

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

//高々000-999の1000個

void solve(void)
{
    int n;
    string s;
    cin >> n >> s;
    vector<map<char, int>> v(10);
    int ans = 0;
    rep(i, 1000)
    {
        int x = i;
        vector<char> c(3);
        rep(j, 3) c[j] = x % 10 + '0', x /= 10;
        reverse(all(c));
        int tmp = 0;
        int l, m, r;
        l = 0;
        while (s[l] != c[0] && l < n)
            l++;
        m = l + 1;
        while (s[m] != c[1] && m < n)
            m++;
        r = m + 1;
        while (s[r] != c[2] && r < n)
            r++;
        if (r < n)
            ans++;
    }
    cout << ans << endl;
}

int main(void)
{
    solve();
}


Measured memory_bytes: 3696
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
multiset<long long>mst;
long long a[100007];
int main(){
    long long n;
    cin>>n;
    long long x;
    for(long long i=0;i<n;++i){
        cin>>x;
        a[x]=i;
    }
    mst.insert(-1);
    mst.insert(-1);
    mst.insert(n);
    mst.insert(n);
    long long ans=0;
    multiset<long long>::iterator pos,nex,pre,pree;
    for(long long i=n;i;--i){
        pos=mst.upper_bound(a[i]);
        nex=next(pos);
        pre=prev(pos);
        pree=prev(pre);
        ans+=i*((*nex-*pos)*(a[i]-*pre)+(*pos-a[i])*(*pre-*pree));
        mst.insert(a[i]);
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

int main() {
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  vector<int> l, r;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'x') continue;
    l.emplace_back(i + 1);
    i += c;
  }

  reverse(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    if (s[i] == 'x') continue;
    r.emplace_back(n - i);
    i += c;
  }
  reverse(r.begin(), r.end());

  if (r.size() > k) {
    return 0;
  }
  for (int i = 0; i < r.size(); i++) {
    if (r[i] == l[i]) {
      cout << r[i] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3448
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{			
		//文字列を読み込む
		int[] input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		int N = input[0];
		int R = input[1];
		
		if(N < 10){
				R += 100*(10 - N);
		}
		
		Console.WriteLine(R);
	}
}

Measured memory_bytes: 13268
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

X = INT()
lim = 10**5+1
dp = [0]*lim
t = [100 + i for i in range(6)]

for i in range(6):
	dp[100+i] = 100+i

for j in range(106, lim):
	dp[j] += sum([dp[j-k] for k in t])

if dp[X] == 0:
	print("0")
else:
	print("1")

Measured memory_bytes: 26152
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

class UnionFind {
 private:
  vector<int> _par, _size;

 public:
  UnionFind(int N) : _par(N), _size(N, 1) {
    for (int i = 0; i < N; i++) _par[i] = i;
  }

  int root(int x) {
    return _par[x] == x ? x : _par[x] = root(_par[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (_size[x] < _size[y]) swap(x, y);
    _size[x] += _size[y];
    _par[y] = x;
    return true;
  }

  bool is_same(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return _size[root(x)];
  }
};

int main() {
  init();

  int N, M, K;
  cin >> N >> M >> K;
  vi A(M), B(M), C(K), D(K);
  rep(i, M) cin >> A[i] >> B[i];
  rep(i, K) cin >> C[i] >> D[i];

  UnionFind uf(N);
  vvi friends(N), blocks(N, vi(0));
  rep(i, M) {
    uf.unite(A[i] - 1, B[i] - 1);
    friends[A[i] - 1].push_back(B[i] - 1);
    friends[B[i] - 1].push_back(A[i] - 1);
  }
  rep(i, K) {
    blocks[C[i] - 1].push_back(D[i] - 1);
    blocks[D[i] - 1].push_back(C[i] - 1);
  }

  rep(i, N) {
    int ans = uf.size(i) - friends[i].size() - 1;
    rep(j, blocks[i].size()) {
      if (uf.is_same(blocks[i][j], i)) ans--;
    }
    if (i != 0) cout << ' ';
    cout << ans;
  }
  cout << endl;
}


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int a, b;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> a >> b;
  if (a <= 0 && b >= 0)
    cout << "Zero\n";
  else if (b < 0 && (b - a + 1) % 2 == 1)
    cout << "Negative\n";
  else
    cout << "Positive\n";
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var N = input[0];
  var A = input[1].split(" ").map(Number);
  var count = 0;
for(var i=0;i<N;i++){
  while(true){
    if(A[i]%2==0){
      count++;
      A[i] = A[i]/2;
    }else{
      break;
    }
  }
}
  console.log(count);
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21320
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
using Int = long long;
using namespace std;
int main()
{
    int N; cin >> N;
    vector<bool> same(N);
    REP(i, N) {
        char c; cin >> c;
        same[i] = (c == 'o');
    }
    vector<bool> sheep(N);
    REP(i, 4) {
        sheep[0] = ~i & 1;
        sheep[1] = ~i & 2;
        for (int j = 2; j < N; j++) {
            sheep[j] = sheep[j-2] ^ ~same[j-1] ^ ~sheep[j-1];
        }
        if ((sheep[0] == (sheep[N-2] ^ ~same[N-1] ^ ~sheep[N-1])) &&
            (sheep[1] == (sheep[N-1] ^ ~same[0] ^ ~sheep[0]))) {
            REP(i, N) cout << "WS"[sheep[i]];
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main() {
	int y = 700, i;
	char s[4];

	scanf("%s", s);

	for (i = 0; i < 3; i++) {
		if (s[i] == 'o') y += 100;
	}

	printf("%d\n", y);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
int n,m,i;
  cin>>n>>m;
  if(n>=m)
  {
  for(i=1;i<=n;i++)
  {cout<<m;
  }
  cout<<endl;  
  }
else{
  for(i=1;i<=m;i++)
  {cout<<n;
  }
  cout<<endl;
}


}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, m;
	bool* participant;
	
	while (true) {
		cin >> n >> m;
		if (n==0 && m==0) break;
		
		participant = new bool[n];
		for (int i=0; i<n; i++) participant[i] = true;
		
		int index = 0;
		for (int cnt = n; cnt > 0; cnt--) {
			for (int step = m-1; ; index = (index + 1) % n) {
				if (participant[index]) {
					if (step==0) break;
					else step--;
				}
			}
			participant[index] = false;
			// cout << index+1 << " ";
		}
		
		cout << index+1 << endl;
		
		delete[] participant;
	}
	
	return 0;
}

Measured memory_bytes: 3016
import Data.List (sort)

main :: IO ()
main = do
    (_:k:hs) <- map read . words <$> getContents
    print $ minDiff k (sort hs)

minDiff :: Int -> [Int] -> Int
minDiff k xs = minimum diffs
  where
    diffs = zipWith (-) ys xs
    ys    = drop (k-1) xs


Measured memory_bytes: 17660
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics; 

class _Class
{
  void _Do()
  {
    var a = 0;
    var N = Split.ints();
    if (N[2]*2 < N[0] + N[1])
    {
      if (N[3] > N[4])
      {
        var a1 = N[4] * 2 * N[2];
        a1 += N[0] * (N[3] - N[4]);
        var a2 = N[3] * 2 * N[2];
        a = Math.Min(a1,a2);
      }
      else
      {
        var a1 = N[3] * 2 * N[2];
        a1 += N[1] * (N[4] - N[3]);
        var a2 = N[4] * 2 * N[2];
        a = Math.Min(a1, a2);
      }
        
    }
    else
    {
      a = N[0] * N[3] + N[1] * N[4];
    }
    
    //
    Console.WriteLine(a);
   }

  //
  static void Main(string[] args)
  {
    _(args);
    new _Class()._Do();
  }
  [Conditional("DEBUG")]
  static void _(string[] args)
  {
    if (args.Length != 0 && File.Exists(args[0]))
      Console.SetIn(new StreamReader(args[0]));
    else
      Console.Error.WriteLine("in");
  }
}

static class Split
{


  // 1
  public static string[] strings()
  {
    return Console.ReadLine().Split();
  }


  // [2.1] -2,147,483,648 ~ +2,147,483,647
  public static int[] ints()
  {
    var _s = Console.ReadLine().Split();

    var x = new int[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = int.Parse(_s[i]);

    return x;
  }

  // [2.2] 
  // -9,223,372,036,854,775,808 ~ 
  // +9,223,372,036,854,775,807
  public static long[] longs()
  {
    var _s = Console.ReadLine().Split();

    var x = new long[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = long.Parse(_s[i]);

    return x;
  }

  public static double[] doubles()
  {
    var _s = Console.ReadLine().Split();

    var x = new double[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = double.Parse(_s[i]);

    return x;
  }

  public static BigInteger[] bigs()
  {
    var _s = Console.ReadLine().Split();

    var x = new BigInteger[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = BigInteger.Parse(_s[i]);

    return x;
  }
}


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

int main() {
	
	int w,n,f;
	
	while(cin>>w){
		n=1;
		f=0;
		
		for(;n<=512;n<<=1){
			if(w&n){
				cout<<(f?" ":"")<<n;
				f=1;
			}
		}
		cout<<endl;
		
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(3), l(n);
  for (auto& e : a) cin >> e;
  for (auto& e : l) cin >> e;
  int r = 1e9;
  vector<int> b(3);
  for (b[0] = 1; b[0] < (1 << n); b[0]++) {
    for (b[1] = 1; b[1] < (1 << n); b[1]++) {
      if (b[0] & b[1]) continue;
      for (b[2] = 1; b[2] < (1 << n); b[2]++) {
        if ((b[0] & b[2]) || (b[1] & b[2])) continue;
        int rt = 0;
        for (int i = 0; i < 3; i++) {
          int s = 0;
          for (int j = 0; j < n; j++) {
            if (b[i] & (1 << j)) {
              if (s) rt += 10;
              s += l[j];
            }
          }
          rt += abs(a[i] - s);
        }
        r = min(r, rt);
      }
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 256
(defn main [& args]
  (let [n (read)
        m (read)]
    (let [ab (into [] (for [i (range n)] [(read) (read)]))
          cd (into [] (for [i (range m)] [(read) (read)]))]
      (doseq [i (range n)]
        (let [min_  (atom Integer/MAX_VALUE)
              index (atom 0)]
          (doseq [j (range m)]
            (let [distance (+ (Math/abs (- ((ab i) 0) ((cd j) 0)))
                              (Math/abs (- ((ab i) 1) ((cd j) 1))))]
              (when (> @min_ distance)
                (reset! min_ distance)
                (reset! index j))))
          (println (+ @index 1)))))))
(main)


Measured memory_bytes: 81256
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);} while(0)
  #define trcc(v) do { cerr << "name : " << #v << "\n"; int cnt = 0; each(x , v){cerr << (cnt++) << " : "; trc(x); } } while(0)
#else
  #define trc(...)
  #define trca(...)
  #define trcc(...)
  int main(){solve();}
#endif

#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(s,t)   rep(i,sz(s)){in(s[i] , t[i]);}
#define in3(s,t,u) rep(i,sz(s)){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////

void solve(){
  inl(N,A,B);
  vl a(N); in(a);
  ll ans = 0;
  rep(i , N - 1){
    ans += min(B , A * (a[i + 1] - a[i]) );
  }
  out(ans);

}

Measured memory_bytes: 1024
#include <vector>
#include <cassert>
#include <iostream>
using namespace std;
const int mod = 1000000007;
int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int> > dp(H + 1, vector<int>(W, 0)); dp[0][0] = 1;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			for (int k = 0; k < 1 << (W - 1); ++k) {
				// Check if two horizontal lines are connecting
				// 2 つの横線がつながっていないか調べる
				bool ok = true;
				for (int l = 0; l < W - 2; ++l) {
					if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
						ok = false;
					}
				}
				if (ok) {
					if (j >= 1 && ((k >> (j - 1)) & 1)) {
						// The case which goes left
						// 左方向に横線をたどるケース
						dp[i + 1][j - 1] += dp[i][j];
						dp[i + 1][j - 1] %= mod;
					}
					else if (j <= W - 2 && ((k >> j) & 1)) {
						// The case which goes right
						// 右方向に横線をたどるケース
						dp[i + 1][j + 1] += dp[i][j];
						dp[i + 1][j + 1] %= mod;
					}
					else {
						// The case which goes straight
						// 横線をたどらないケース
						dp[i + 1][j] += dp[i][j];
						dp[i + 1][j] %= mod;
					}
				}
			}
		}
	}
	cout << dp[H][K - 1] << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define F  first
#define S  second
#define ff(i,n) for(i=0;i<n;i++)
ll bg = 1000000000000000000;
ll power(ll x,ll y)
{
	if(y==0)
		return 1;
	ll h=power(x,y/2)%bg;	
	h=(h*h)%bg;
	if(y%2==1)
	  return (x*h)%bg;
	else
	  return h%bg;  
}
ll modinv(ll m)
{
	return power(m,bg-2)%bg;
}
ll sum(ll i)
{
	ll s = (i*(i+1))/2;
	return s;
}
int main()
{ 
	ll t;
	t=1;
	while(t--)
	{
		ll i,n,m;
		cin>>n;
		ll d = 1,flag = 1;
		ll arr[n];
		for(i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]==0)
			   flag = 0;	
		}		
		if(flag == 0)
		   cout<<0;
		else
		{
		    ff(i,n)
			{
				ll ss = bg/d;
				if(ss<arr[i])
				{
					d = -1;
					break;
				}
				d = d*arr[i];
				if(d>bg)
				   break;
			}  	
			cout<<d<<endl;
		}   
	}
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T){
  string ans = (S == T.substr(0, T.size()-1)) ? YES : NO;
  cout << ans << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
 
int main(void) {
int a,b,c;
scanf("%d %d %d ",&a,&b,&c);
int d,e,f;
d=a+b;
e=b+c;
f=a+c;
if((d<=e)&&(d<=f))
printf("%d",d);
else if((e<=d)&&(e<=f))
printf("%d",e);
else if((f<=e)&&(f<=d))
printf("%d",f);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A_ls=list(map(int, input().split()))
Q = int(input())

adhoc=sum(A_ls)
import collections
A_dict=collections.Counter(A_ls)

for wamimiavioawmifwe in range(Q):
	B,C=map(int, input().split())
	adhoc=adhoc+A_dict[B]*(C-B)
	A_dict[C]+=A_dict[B]
	A_dict[B]=0
	print(adhoc)


# 2darray [[0] * 4 for i in range(3)]

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    string n;
    cin >> n;
    int l = n.size();

    int sum = 0;
    rep(i,l){
        int digit = n[i] - '0';
        sum += digit;
    }

    Ans(sum%9==0);

    return 0;
}

Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner a = new Scanner(System.in);
		int h =1;
		int w = 1;
		while(h > 0 && w > 0){
		h = a.nextInt();
		w = a.nextInt();
		
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(i ==0 || i == (h-1) || j == 0 || j ==(w-1)){
				System.out.print("#");
				}else{
					System.out.print(".");
				}
				
			}
			if(h != 0 && w != 0)
			System.out.println();
		}
		if(h != 0 && w != 0)
		System.out.println();
	}
	}

}

Measured memory_bytes: 24836
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	string S,T;
	cin >> S >> T;
	int ret = 0;
	for(int i = 0;i < S.size();i++) {
		if(S.at(i) == T.at(i)) {
			ret++;
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		BigDecimal result = BigDecimal.ONE;
		BigDecimal divisor = new BigDecimal("1000000007");
		for(int i = 1; i <= N; i++) {
			result = result.multiply(BigDecimal.valueOf(i)).remainder(divisor);
		}
		System.out.println(result.toString());
		sc.close();
	}
}


Measured memory_bytes: 57148
#include <bits/stdc++.h>
using namespace std;
int h,w,k;

vector<int> gyoucut(string gyou, int cakeid){
    int cakecount = 0;
    vector<int> out;
    for(int i=0; i<w; i++){
        if(gyou.at(i)=='#')cakecount++;
    }
  //cout << cakecount;
    int count = 0;
    for(int i=0; i<w; i++){
        if(gyou.at(i)=='.'){
            count++;
        }else{
          if(cakecount!=1){
            for(int j=0; j<count+1; j++){
                out.push_back(cakeid);
            }
            cakeid++;
          cakecount--;
            count = 0;}
        }
    }
    for(int j=0; j<count+1; j++){
        out.push_back(cakeid);
    }
    return out;
}
    
        
        
        
    
    

int main(){
    //int h,w,k;
    cin >> h >> w >> k;
    vector<string> cake;
    string noc(w,'.');
    vector<int> h_nocake(h);
    vector<int> aru;
    string tmp;
    for(int i=0; i<h; i++){
        cin >> tmp;
        if(tmp==noc){h_nocake.at(i)=1;}
        else aru.push_back(i);
        cake.push_back(tmp);
    }
  vector<int> it;
  int id=1;
  vector<int> outnow;
  outnow = gyoucut(cake.at(aru.at(0)), id);
  //id = outnow.at(outnow.size()-1)+1;
  for(int i=0; i<h; i++){
    if(h_nocake.at(i)==1){
      for(int j=0; j<w; j++){
        cout << outnow.at(j) << ' ';
      }
      cout << endl;
    }else{
      outnow = gyoucut(cake.at(i), id);
      id = outnow.at(outnow.size()-1)+1;
      for(int j=0; j<w; j++){
        cout << outnow.at(j) << ' ';
      }
      cout << endl;
    }
  }

}


    
    //int cakeid = 1;
    //vector<int> cakebuf(w);
    //for(int j=0; j<h; j++){
    

        
    
    

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

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

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);

    string s;
    cin >> s;

    bool f1 = false, f2 = false, f3 = false;
    int n = s.size();
    if (s[0] == 'A')
        f1 = true;

    int cnt = 0;
    for (int i = 2; i < n - 1; ++i)
    {
        if (s[i] == 'C')
            cnt++;
    }
    if (cnt == 1)
        f2 = true;

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

    int c = 0;
    for (int i = 0; i < n; ++i)
    {
        if (s[i] >= 'a' && s[i] <= 'z')
            continue;
        if (s[i] >= 'A' && s[i] <= 'Z')
            c++;
    }
    if (c == 2)
        f3 = true;
    if (f1 && f2 && f3)
        cout << "AC" << endl;
    else
        cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
int const mod = 998244353;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x , int m){
    return power(x,m-2,m);
}

int const N = 2e5+5;
int const inf = 2e16;

void solve(){  
    int i,j,l;
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> a(n);
    for(auto &x:a){
        cin>>x;
    }
    for(i=1;i<n;i++){
        a[i] += a[i-1];
    }
    a.pb(inf);

    int ans = 0;

    ans = lower_bound(all(a) , k+1) - a.begin();

    // cout<<ans<<endl;

    int sm = 0;
    for(i=0;i<m;i++){
        int x;
        cin>>x;
        sm += x;
        int l = lower_bound(all(a) , k-sm+1) - a.begin();
        if(k-sm >= 0)
        ans = max(ans , i+1 + l);
    }

    cout<<ans<<endl;
}           


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 6368
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        p: [usize; n],
    }

    let mut ans = 0;

    for i in 1..n-1 {
        let mut t = vec![p[i-1], p[i], p[i+1]];
        t.sort();
        if p[i] == t[1] {
            ans += 1;
        }
    }

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


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{  string s1,s2;
  cin>>s1>>s2;
int ret=0;
 for(int i=0;i<s1.length();i++)
 { if(s1[i]!=s2[i])
 {  ret=-1;
    break;
 }
 }
 if(ret==-1)
    cout<<"No";
  else
    cout<<"Yes";
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void)
{
	double a;
	int i;
	char box[12]={'0','0','0','0','0','0','0','0','0','0','0','0'};
	double nisin[12]={128.0,64.0,32.0,16.0,8.0,4.0,2.0,1.0,0.5,0.25,0.125,0.0625};

	cin >> a;
	while(a>0.0){
		for(i=0;i!=12;i++){
			if(a>=nisin[i]){
				a=a-nisin[i];
				box[i]='1';
			}
		}
		if(a==0.0){
			for(i=0;i!=12;i++){
				cout << box[i];
				if(i==7){
					cout << '.';
				}
			}
		}
		else{ 
			cout << "NA";
		}
		cout << endl;
		for(i=0;i!=12;i++){
			box[i]='0';
		}
		cin >> a;
	}
	return 0;
}

Measured memory_bytes: 1216
n, k = map(int, input().split())

d = list(map(int, input().split()))

n_list = list(str(n))
n_list = [int(num) for num in n_list]

num = {1,2,3,4,5,6,7,8,9,0}

d_set = set(d)
empty = set()
#print(set(n_list))
#print(d_set)
#print(set(n_list) & d_set)
while(1):
  n_list = list(str(n))
  n_list = [int(num) for num in n_list]
  if(set(n_list) & d_set == empty):
    print(n)
    break
  n += 1
  


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

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

    if (A + W < B) {
        cout << (B - A - W) << endl;
    } else if (B + W < A) {
        cout << (A - B - W) << endl;
    } else {
        cout << 0 << endl;
    }
}



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

int main() {
	int n, k;
	cin >> n >> k;
	map<int, int>a;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (a.count(x))a.at(x)++;
		else a[x] = 1;
	}
	vector<int>b(n);
	for (auto y : a) b.push_back(y.second);
	sort(b.begin(), b.end());
	ll ans = 0;
	for (int i = 0; i < b.size() - k; i++)ans += b.at(i);
	cout << ans << endl;

}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 2e5+2;
unsigned long long nums[MAXN];
 
const long long MAXL = 1e18;
 
bool overflow(unsigned long long a, unsigned long long b) {
    if (ULLONG_MAX / a < b) {
        return true;
    }
    unsigned long long ans = a*b;
    if (ans>MAXL) {
        return true;
    }
    return false;
}
 
int main() {
    int n;
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        scanf("%llu", &nums[i]);
        if (0==nums[i]) {
            printf("0\n");
            return 0;
        }
    }
 
    long long ans=1;
    for (int i=0; i<n; i++) {
        if (true == overflow(ans, nums[i])) {
            printf("-1\n");
            return 0;
        }
        ans *= nums[i];
    }
 
    printf("%llu", ans);
 
    return 0;
}

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

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

    int res = 0;


    while (true) {
        bool exist_odd = false;  
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true; 
        }

        if (exist_odd) break; 

   
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res; 
    }

    cout << res << endl;
}


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

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

long long count(int mask, long long n) {
	long long ret = 0;
	long long cur = 0;
	while (n) {
		cur = cur*10+n%10;
		if (mask&1) {
			ret += cur;
			cur = 0;
		}
		n /= 10;
		mask >>= 1;
	}
	return ret+cur;
}

void solve() {
	long long n; scanf("%lld", &n);
	long long ans = 0;
	long long m = n, c = -1;
	long long newN = 0;
	while (m) {
		newN = newN*10+m%10;
		m /= 10;
		++c;
	}
	for (int i = 0; i < 1<<c; ++i) {
		ans += count(i, newN);
	}
	printf("%lld", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int i,c;
int main(){
  cin>>s;
  for(i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      c++;
      if(s[i+1]=='0')
        s[i+1]='1';
      else
        s[i+1]='0';}}
  cout<<c;}

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

//------------Constants----------------
#define N 21
//------------Variables----------------
int n,hmax,ans;
int a[N];
//------------Functions----------------

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//------------Input--------------------
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    for (int i=0; i<n; i++) cin >> a[i];
//------------Work---------------------
    hmax=a[0];
    ans=1;
    for (int i=1; i<n; i++){
        if (a[i]>=hmax) {hmax=a[i]; ans++;}
    }
    cout << ans;
}


Measured memory_bytes: 256
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#n = int(input())
s, w = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

if s > w:
    print("safe")
else:
    print("unsafe")


    


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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    double odd = (N + 1) / 2;
    double p = odd / N;

    cout << fixed << setprecision(7);
    cout << p << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int div2(int n);

int main(void)
{

   int n,i,d=0;
   int *p;

   scanf("%d",&n);
   p=(int*)malloc(sizeof(int)*n);

   for(i=0;i<n;i++){
      scanf("%d",p+i);
      d+=div2(*(p+i));
   }

   printf("%d\n",d);
   free(p);
   return 0;

}

int div2(int n)
{
   int i=0;

   while(1){
      if(n%2==1)
         return i;
      else{
         n/=2;
         i++;}
      }
}


Measured memory_bytes: 256
#include<stdio.h>

#define max 100000

int X[max], n;

int P(int p, int r){
  int a, i, j, tmp;
  a=X[r];
  i=p-1;
  for(j=p ; j<r ; j++){
    if(X[j]<=a){
      i++;
      tmp=X[i];
      X[i]=X[j];
      X[j]=tmp;
    }
  }
  tmp=X[i+1];
  X[i+1]=X[r];
  X[r]=tmp;
  return i+1;
}

int main(){
  int i, q;
  scanf("%d", &n);
  for(i=0 ; i<n ; i++)scanf("%d", &X[i]);
  q=P(0, n-1);
  printf("%d", X[0]);
  for(i=1 ; i<n ; i++){
  printf(" ");
  if(i==q)printf("[");
  printf("%d", X[i]);
  if(i==q)printf("]");
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2084
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))


arr = []
for i in range(n):
    arr.append(t - h[i]*0.006)

diff = []
for i in range(n):
    diff.append(abs(arr[i] - a))

index = -1
m = 10**12
for i in range(n):
    if m >= diff[i]:
        m = diff[i]
        index = i

print(index + 1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  
  int j=1;
  int bb=b;
  
  while(bb>=10){
    bb/=10;
    j++;
  }
  
  for(int i=0;i<j;i++){
    a*=10;
  }
  a+=b;
  
  int k=0;
  
  for(int i=0;i<=316;i++){
    if(i*i==a){
      k++;
      break;
    }
  }
  
  if(k==0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  
}

Measured memory_bytes: 256
import heapq
 
N, M = [int(item) for item in input().rstrip().split()]
hp = [-1 * int(item) for item in input().rstrip().split()]
heapq.heapify(hp)

for i in range(M):
    _t = heapq.heappop(hp)
    heapq.heappush(hp, -1 * (-1 * _t // 2))
    
_sum = sum([-1 * int(item) for item in hp])
print(_sum)


Measured memory_bytes: 14180
import collections

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr) #小さい順にソートしておく
s=set()
cnt=collections.Counter(arr) #各要素の個数を事前に数えておく
for i in range(n):
 if arr[i] in s: #Aiがすでに列挙した数に含まれていれば処理を行わない
   continue
 if cnt[arr[i]]>=2: #Aiが2個以上含まれているとき、Ai自身を列挙した数に加える
   s.add(arr[i])
 for j in range(2,10**6//arr[i]+1): #Ai自身を除くAiの倍数を列挙する
   s.add(arr[i]*j)
ans=0
for i in range(n): #列挙した数に含まれないAiの個数を数える
 if arr[i] in s:
   continue
 ans+=1
print(ans)

Measured memory_bytes: 103144
import java.util.Scanner;

public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		int dice[] = new int[6];
		int dice2[] = new int[6];
		String direction;
		
		for (int i = 0; i < 6; i++) {
			dice[i] = scan.nextInt();
			dice2[i] = dice[i];
		}
		
		direction = scan.next();
		
		for (int i = 0; i < direction.length(); i++) {
			switch(direction.charAt(i)) {
			case 'N':
				dice2[0] = dice[1];
				dice2[1] = dice[5];
				dice2[4] = dice[0];
				dice2[5] = dice[4];
				break;
			case 'E':
				dice2[0] = dice[3];
				dice2[2] = dice[0];
				dice2[3] = dice[5];
				dice2[5] = dice[2];
				break;
			case 'S':
				dice2[0] = dice[4];
				dice2[1] = dice[0];
				dice2[4] = dice[5];
				dice2[5] = dice[1];
				break;
			case 'W':
				dice2[0] = dice[2];
				dice2[2] = dice[5];
				dice2[3] = dice[0];
				dice2[5] = dice[3];
				break;
			default:
				break;
			}
			
			for( int j = 0; j < 6;j++) {
				dice[j] = dice2[j];
			}
		
		}
		
		scan.close();
		System.out.println(dice[0]);
	}
}


Measured memory_bytes: 26420
import math

def jds(strin):
    js = 0
    newSt = strin[::-1]
    if strin == newSt:
        js +=1
    return js
 
a = input()
jud = 0

leee = len(a)

if leee % 2 == 0:
    b = a[:math.ceil((len(a) - 1) / 2)]
    c = a[math.floor((len(a) + 1) / 2):]
else:
    b = a[:int((len(a) - 1) / 2)]
    c = a[int((len(a) + 2) / 2):]
 
jud += jds(a) + jds(b) + jds(c)
 
#print(jud)
if jud == 3:
    print("Yes")
else:
    print("No")

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

int main() {
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if ((x > 0 && y >0) && (x + r <= W && y + r <= H)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
    


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N;
    cin >> N;
    vector<int64_t>vec(N);
    for (int64_t i=0; i<N; i++) {
        cin >> vec.at(i);
    }

    vector<bool>itta(N, false);
    int64_t push_count = 0;
    int64_t next_ = 0;
    while (next_ != 1) {
        if (itta[next_]) {
            push_count = -1;
            break;
        }

        itta[next_] = true;
        int64_t i = vec[next_];
        push_count += 1;
        next_ = i - 1;
    }

    cout << push_count << endl;
    return 0;
}

Measured memory_bytes: 4044