akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集

int dxy[5]={-1,0,1,0,-1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
    
  int H, W, K;
  cin >> H >> W >> K;
  int sx, sy, gx,gy;
  cin >> sy >> sx >> gy >> gx;
  sx--;
  sy--;
  gx--;
  gy--;
  vector<string> f;
  REP(i,H){
    string s; cin >> s;
    f.push_back(s);
  }

  queue<pair<int, int>> q;
  q.push({sy, sx});
  vector<vector<int>> dist(H, vector<int>(W, INT_MAX));
  dist[sy][sx] = 0;
  while(q.size()){
    auto p = q.front();
    q.pop();

    int y = p.first, x = p.second;
    //cout << y << " " << x << endl;
    for(int k=0; k<4; k++){
      for(int d=1; d<=K; d++){
        int nx = x + d*dxy[k], ny = y + d*dxy[k+1];
        if(!(ny >= 0 && ny < H && nx >= 0 && nx < W && f[ny][nx] != '@')) break;
        if(dist[ny][nx] <= dist[y][x]) break;

        if(dist[ny][nx] == INT_MAX){
          dist[ny][nx] = dist[y][x] + 1;
          q.push({ny, nx});
        } 
      }
    }
  }

  int ans = dist[gy][gx];
  if(ans == INT_MAX) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12128
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
map<int, int> cnt;
int main() {
  int n;
  cin >> n;
  cout << 1.0 * (n / 2 + n % 2) / n;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

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

	int A;
	cin >> A;
	cout << ((A % 2) ? A * 2 : A) << endl;;

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}




Measured memory_bytes: 504
*D, = open(0)
n = int(D[0])

edge = [[] for _ in range(n+1)]
v_val = [0 for _ in range(n+1)]

dist = {}

for i in range(1, n):
    a, b = map(int, D[i].split())
    edge[a].append(b)
    edge[b].append(a)
c = list(map(int, D[n].split()))
c = sorted(c, reverse=True)

start = None
for i in range(1,len(edge)):
    if len(edge[i])==1:
        start = i
        break

        
import sys
sys.setrecursionlimit(10**7)


def visit(edge, start, visited, order):
    visited[start] = True
    order.append(start)
    
    for node in edge[start]:
        if not visited[node]:
            visit(edge, node, visited, order)
    
    return 

visited = [False for _ in range(len(edge))]
order = []
visit(edge, start, visited, order)

# calculate cost
v_val = [0 for _ in range(len(c)+1)]
for i, it in enumerate(order):
    v_val[it] = c[i]
    
print(sum(c[1:]))
print(' '.join(map(str, v_val[1:])))

Measured memory_bytes: 15092
a = input()
count = [0 for _ in range(len(a))]
walk_Right = [0 for _ in range(len(a))]
walk_Left = [0 for _ in range(len(a))]
c = 0
for i in range(len(a)-1,-1,-1):
    if a[i] == 'R':
        c += 1
        walk_Right[i]=c
    else:
        c = 0
        walk_Right[i]=c

c=0
for i in range(len(a)):
    if a[i] == 'L':
        c += 1
        walk_Left[i]=c
    else:
        c = 0
        walk_Left[i]=c

for i in range(len(a)):
    if a[i] == 'R':
        if walk_Right[i] % 2 == 0:
            count[i+ walk_Right[i]] += 1
        else:
            count[i + walk_Right[i] - 1] += 1
    else:
        if walk_Left[i] % 2 == 0:
            count[i - walk_Left[i]] += 1
        else:
            count[i- walk_Left[i] + 1] += 1
print(* count)





Measured memory_bytes: 11128
<?php

fscanf(STDIN, '%d %d', $n, $q);
$queue = array();
$result = array();
for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, '%s %d', $name, $time);
    $queue[] = array('name' => $name, 'time' => $time);
}

$total = 0;
while (count($result) !== $n) {
    $queue2 = array();
    foreach ($queue as $i => $arr) {
        if ($arr['time'] <= $q) {
            $total += $arr['time'];
            $result[] = sprintf("%s %d\n", $arr['name'], $total);
        } else {
            $arr['time'] -= $q;
            $total += $q;
            $queue2[] = $arr;
        }
    }
    $queue = $queue2;
}

echo implode('', $result);

Measured memory_bytes: 60096
N=int(input())
lxy=[]
for i in range(N):
    lxy.append(list(map(int,input().split())))
def fac(n):
    ans=1
    for i in range(1,n+1):
        ans*=i
    return ans
def dij(l1,l2):
    return ((l1[0]-l2[0])**2+(l1[1]-l2[1])**2)**0.5
#ans=0
dsum=0
for i in range(N):
    for j in range(i+1,N):
        dsum+=dij(lxy[i],lxy[j])
print(2*dsum/N)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	int N;
	cin>>N;
	cout<<(1000-(N%1000)) % 1000<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
const ll N=998244353;
void solve()
{
    ll n, r;
    cin>>n>>r;
    if(n<10)
    {
        cout<<100*(10-n)+r;
    }
    else
    cout<<r;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll k;
    cin >> k;

    ll n = min(50LL, k);
    chmax(n, 2LL);
    vector<ll> v(n, n-1 + k/n);

    REP(i, n){
        if(i+1 <= k%n){
            v[i]++;
        }else{
            v[i] -= k%n;
        }
    }

    cout << n << endl;
    REP(i, n){
        cout << v[i] << " \n"[i == n - 1];
    }

    return 0;
}


Measured memory_bytes: 256
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


def main():
    a, b = map(int, input().split())
    b_divide = divisor(b)
    if a in b_divide:
        ans = a + b
    else:
        ans = b - a
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll (i) = 0; (i) < (n); ++(i))

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> v(n);
    REP(i,n)cin >> v[i];
    vector<ll> diff(n-1, 0);
    REP(i,n-1)diff[i] = v[i+1] - v[i];

    sort(diff.begin(), diff.end(), greater<ll>());
    ll minu = 0;
    REP(i,k - 1)minu += diff[i] - 1;
    cout << v.back() - v.front() + 1 - minu << endl;
}



Measured memory_bytes: 4412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>

int main() {
	long long a, b, k;

	std::cin >> a >> b >> k;

	if (a <= k) {
		long long tmp = k;
		k -= a;
		a = 0;
	}
	else {
		a -= k;
		k = 0;
	}

	b = std::max(b - k, 0LL);

	std::cout << a << " " << b << std::endl;

	return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  string t;

  int count_A = 0;
  int64_t answer = 0;

  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'A') {
      count_A++;
    } else if (i + 1 < s.length() && s[i] == 'B' && s[i + 1] == 'C') {
      answer += count_A;
      i++;
    } else {
      count_A = 0;
    }
  }

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=list(map(int,input().split()))
b.sort()
c=list(map(int,input().split()))
c.sort()
ans=0
import bisect
for bb in b:
  ao=bisect.bisect(a,bb-1)
  cnta=ao
  cs=bisect.bisect(c,bb)
  cntc=n-cs
  ans+=cnta*cntc
print(ans)

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

using namespace std;
using ll = long long;

const int MAX { 2050 };
const ll MOD { 1000000007 };

ll binom[MAX][MAX];
void precomp()
{
    binom[0][0] = 1;

    for (int n = 1; n < MAX; ++n)
    {
        binom[n][0] = binom[n][n] = 1;

        for (int m = 1; m < n; ++m)
            binom[n][m] = (binom[n - 1][m] + binom[n - 1][m - 1]) % MOD;
    }
}

vector<int> solve(int N, int K)
{
    vector<int> ans(K);

    for (int i = 1; i <= K; ++i)
    {
//cout << "i = " << i << endl;
//cout << "bin[" << K - 1 << "][" << i - 1 << "] = " << binom[K - 1][i - 1] << endl;
//cout << "bin[" << N - K + 2 << "][" << i + 1 << "] = " << binom[N - K + 1][i] << endl;
        ans[i - 1] = (binom[K - 1][i - 1] * binom[N - K + 1][i]) % MOD;
    }

    return ans;
}

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

    int N, K;
    cin >> N >> K;

    auto ans = solve(N, K);

    for (auto x : ans)
        cout << x << '\n';

    return 0;
}


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

using namespace std;

int main(void) {
    int N, Y;
    cin >> N >> Y;
    int x = -1;
    int y = -1;
    int z = -1;

    for(int i = 0; i < N+1; i++) {
        for (int j = 0; j < N+1; j++) {
            if (N < (i + j)) {
                break;
            }
            for (int k = 0; k < N+1; k++) {
                if (N < (i + j + k)) {
                    break;
                }
                unsigned long sum = (10000 * i) + (5000 * j) + (1000 * k);
                if ((sum == Y) && ((i + j + k) == N)) {
                    x = i;
                    y = j;
                    z = k;
                }
                if (x != -1) break;
            }
            if (x != -1) break;
        }
        if (x != -1) break;
    }

    cout << x << ' ' << y << ' ' << z << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define Int int64_t
 
using namespace std;
 
int main() {
	int N;
	cin >> N;

	vector<vector<char>> ans;
	deque<vector<char>> que;
	que.push_back(vector<char>(1, 'a'));
	while (!que.empty()) {
		auto v = que.front(); que.pop_front();
		if (v.size() == N) {
			ans.push_back(v);
			continue;
		}

		vector<bool> used(26, false);
		for (auto c : v) { used[c - 'a'] = true; }
		int idx = 0;
		for (int i = 0; i < 26; ++i) {
			if (!used[i]) {
				idx = i;
				break;
			}
		}

		v.push_back('a' + idx);
		que.push_back(v);
		for (int i = 0; i < 26; ++i) {
			if (used[i]) {
				v.back() = 'a' + i;
				que.push_back(v);
			}
		}
	}

	vector<string> s;
	for (auto v : ans) {
		string t = "";
		for (auto c : v) { t = t + c; }
		s.push_back(t);
	}
	sort(s.begin(), s.end());
	for (auto v : s) { cout << v << endl; }

	return 0;
}


Measured memory_bytes: 14448
/* ex 7_1
   KKOO */

#include <stdio.h>

typedef struct point{
    int x_elem;
    int y_elem;
}point;

//点pをx軸方向に+x,y軸方向に+yだけ移動した点を返す関数
point shift_point(point p, int x, int y){
    p.x_elem += x;
    p.y_elem += y;
    return p;
}

int main(void){
    point p1, p2, p3, p4;

    scanf("%d%d%d%d", &p1.x_elem, &p1.y_elem, &p2.x_elem, &p2.y_elem);

    p3 = shift_point(p2, p1.y_elem - p2.y_elem, p2.x_elem - p1.x_elem);
    p4 = shift_point(p1, p1.y_elem - p2.y_elem, p2.x_elem - p1.x_elem);

    printf("%d %d %d %d\n", p3.x_elem, p3.y_elem, p4.x_elem, p4.y_elem);

    return 0;
}


Measured memory_bytes: 1712
#include <iostream>
#include <algorithm>
using namespace std;
 
 
long long int check(int arr[], int N){
	if (N%2 and arr[0]!=0) return 0;
	long long int n=1;
	for (int i = N%2; i<N-1; i+=2){
		//cout << 'D'<< d << "i" <<i << endl;
		//cout << arr[i] << arr[i+1] << endl;
		if (arr[i]!=i+1 or arr[i+1]!=arr[i]){
			return 0;
		}
		n=(n*2)%1000000007;
	}
	return n;
}
int main() {
	int N;
	cin>>N;
	int arr[N];
	for (int i=0; i<N; i++){
		cin>>arr[i];//{02244}{11335577}
	}
	sort(arr, arr+N);
 
	cout << check(arr, N) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;


int main()
{
	int l, r, d;
	cin >> l >> r >> d;
	int cnt = 0;
	for (int i = l;i <= r;i++) {
		if (i % d == 0) cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  s += s;
  for (int i=0; i<t.length(); i++) {
    int check = 0;
    for (int j=0; j<t.length(); j++) {
      if (s[i+j]!=t[j]) check = 1;
    }
    if (check == 0) {
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
}

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

int main() {
  int a, b, c, d, X;
  cin >> X;
  
  b = X;
  c = 100000000;
  for ( ;b != 0; ){
    a += b / c;
    b %= c;
    c /= 10;
  }
  
  d = X % a;
  if (d) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#A
import math
inf = 2**31 - 1

N,Q = map(int,input().split())

K = 1
while K < N:
    K *= 2


RMQ = [inf for _ in range(2*K-1)]
def find(s,t,i,l,r):
    if s > r or t < l:
        return inf
    
    if s <= l and t >= r:
        return RMQ[i]
    else:
        ml = find(s,t,2*i+1,l,(l+r)//2)
        mr = find(s,t,2*i+2,(l+r)//2+1,r)
        return min(ml,mr)
    

for _ in range(Q):
    c,x,y = map(int,input().split())
    
    if c == 0:
        RMQ[K+x-1] = y
        now = K+x-1
        while now > 0:
            n1 = now
            if now%2 == 0:
                now = now//2 - 1
            else:
                now //= 2
            RMQ[now] = min(RMQ[2*now+1],RMQ[2*now+2])
            
    else:
        print(find(x,y,0,0,(2*K-1)//2))
            
        
        




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

int main() {
	int n;
	int a[200];
	int count = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool isEven = true;
	while (isEven) {
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 1) {
				isEven = false;
				break;
			}
		}
		if (isEven) {
			count++;
		}
		for (int i = 0; i < n; i++) {
			a[i] /= 2;
		}
	}

	cout << count << endl;


	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <stack>
#include <list>
#include <bitset>
#include <iostream>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
typedef long long ll;
const int maxn=200050;
char s[maxn];

void solve(){
	scanf("%s",s);
	int len_s=strlen(s);
	if(s[len_s-1]!='s')	printf("%ss\n",s);
	else	printf("%ses\n",s);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 202020;
char s[N] , tp[N];int _;


int main(){
    scanf("%s",s);
    int n = strlen(s);
    rep(i,0,n){
        if(s[i] == 'S') tp[_++] = s[i];
        else if(s[i] == 'T'){
            if(_ > 0 && tp[_-1] == 'S') --_;
            else tp[_++] = s[i];
        }
    }
    printf("%d\n",_);
    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    s[1] = 'B' ^ 'R' ^ s[1];
    cout << s << endl;
    return 0;
}


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

using namespace std;

int main() {
  long long n; cin >> n;
  long long sx = (long long)sqrt(n);
  long long ans = (long long)1e15;
  for(long long x = 1 ; x <= sx + 5 ; ++x) {
    if(n % x == 0) {
      ans = min(ans, (n / x + x - 2));
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
# E - Bomber

from collections import Counter

h, w, m = map(int, input().split())
hw = [tuple(map(int, input().split())) for i in range(m)]

ys, xs = zip(*hw)
ymax, = Counter(ys).most_common(1)
xmax, = Counter(xs).most_common(1)

bombed = max(ymax[1], xmax[1])

if bombed < m:
    if ymax[1] > xmax[1]:
        xs = [b for a, b in hw if a != ymax[0]]
        xmax, = Counter(xs).most_common(1)
        bombed += xmax[1]
    else:
        ys = [a for a, b in hw if b != xmax[0]]
        ymax, = Counter(ys).most_common(1)
        bombed += ymax[1]

print(bombed)


Measured memory_bytes: 227280
N,K = map(int,(input().split()))
n_list=[]
ans_list=[]
for i in range(N):
  ans_list.append(i+1)

for i in range(K):
  d = int(input())
  a_list = list(map(int, input().split()))
  n_list.extend(a_list)
  n_list = list(set(n_list))
print(len(list(set(ans_list)-set(n_list))))

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

int main(){
  int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++)
    cin>>vec[i];
  sort(vec.begin(),vec.end());
  int s=0,x=0;
  for(int i=0;i<N-2;i+=2){
    x+=vec[N-i-1]-vec[N-i-2];
    s=i+2;
  }
  x+=vec[N-s-1];
  if(s==N-2)
    x-=vec[0];
  cout<<x<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	
	int n = sc.nextInt()-1;
    int X = sc.nextInt()-1;
    int Y = sc.nextInt()-1;
    int x = Math.min(X, Y);
    int y = Math.max(X, Y);
    int[] a = new int[n];
    
    for(int i=0; i<n+1; i++){
      for(int j=i+1; j<n+1; j++){
        int normal = j-i;
        int warp = Math.abs(j-y)+1+Math.abs(i-x);
        if(normal<warp){
          a[normal-1]++;
        }
        else{
          a[warp-1]++;
        }
      }
    }
    for(int i=0; i<n; i++){
      System.out.println(a[i]);
    }
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int w, a, b;
    cin >> w >> a >> b;
    if (a < b)
        cout << max(0, b-a-w);
    else 
        cout << max(0, a-b-w);
    return 0;
}

Measured memory_bytes: 256
//
// main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
	ll L;
	cin >> L;
	vector<ll> As(L);
	rep(i,0,L) {
		cin >> As[i];
	}
	vector<ll> zeros(L+1);
	vector<ll> evens(L+1);
	vector<ll> odds(L+1);
	vector<ll> sums(L+1);
	rep(n,1,L+1) {
		zeros[n] = zeros[n-1] + (As[n-1] == 0);
		evens[n] = evens[n-1] + (As[n-1] > 0 && As[n-1] % 2 == 0);
		odds[n] = odds[n-1] + (As[n-1] > 0 && As[n-1] % 2 == 1);
		sums[n] = sums[n-1] + As[n-1];
	}
	vector<ll> odd_loss(L+1);
	vector<ll> even_loss(L+1);
	rep(i,0,L+1) {
		odd_loss[i] = zeros[i] + evens[i];
		even_loss[i] = 2*zeros[i] + odds[i];
	}
	vector<ll> min_even_loss_right(L+1);
	min_even_loss_right[L] = even_loss[L];
	rrep(i,L,0) {
		min_even_loss_right[i] = min(min_even_loss_right[i+1], even_loss[i] + sums[L] - sums[i]);
	}
	rep(i,0,L+1) {
		min_even_loss_right[i] -= even_loss[i];
	}
	vector<ll> min_even_loss_left(L+1);
	min_even_loss_left[0] = even_loss[L];
	rep(i,1,L+1) {
		min_even_loss_left[i] = min(min_even_loss_left[i-1], even_loss[L] - even_loss[i] + sums[i]);
	}
	rep(i,0,L+1) {
		min_even_loss_left[i] -= (even_loss[L] - even_loss[i]);
	}
	vector<ll> right_loss(L+1);
	rep(i,0,L+1) {
		right_loss[i] = odd_loss[i] + min_even_loss_right[i];
	}
	vector<ll> right_loss_min(L+2, numeric_limits<ll>::max()); // これいるか？
	rrep(i,L+1,0) { 
		right_loss_min[i] = min(right_loss_min[i+1], right_loss[i]);
	}
	rep(i,0,L+1) { 
		right_loss_min[i] -= odd_loss[i];
	}
	ll loss = numeric_limits<ll>::max();
	rep(i,0,L) {
		ll loss_loc = 0;
		loss_loc += min_even_loss_left[i];
		loss_loc += right_loss_min[i];
		loss = min(loss, loss_loc);
	}
	cout << loss << endl;
}

/*
 
 6
 314159265
 358979323
 846264338
 327950288
 419716939
 937510582
 
 */


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

int main() {
  int N,i,tmp;
  cin>>N;
  for(tmp=0;tmp<(1<<3);tmp++){
    int n=N,x=100,ans=n/1000;
    bitset<3> b(tmp);
    n%=1000;
    for(i=0;i<3;i++){
      if(b.test(i))ans+=n/x;
      else ans-=n/x;
      n%=x;
      x/=10;
    }
    if(ans==7)break;
  }
  bitset<3> b(tmp);
  int x=100;
  cout<<N/1000;
  N%=1000;
  for(i=0;i<3;i++){
    if(b.test(i))cout<<"+";
    else cout<<"-";
    cout<<N/x;
    N%=x;
    x/=10;
  }
  cout<<"=7"<<endl;
}


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

int n,m;
double ans;
double dp[101][101];
double up[101][101];
int main(void){
	for(int i=1;i<=100;i++){
		up[i][0]=1.0;
	}
	while(1){
		memset(dp,0,sizeof(dp));
		ans=0;
		cin >> n >> m;
		if(n==0 && m==0)break;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				cin >> up[j][i];
			}
		}
		dp[0][0]=1;
		for(int i=1;i<=m;i++){
			for(int j=1;j<=n;j++){
				for(int k=0;k<=n;k++){
					dp[i][j]=max(dp[i][j],dp[i-1][k]*up[j][k]);
				}
				if(i==m)ans=max(ans,dp[i][j]);
			}
		}
		printf("%0.2f\n",ans);
	}
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
int main(){
	string i, j ,n;
	cin >> i >> j >> n;
	int cot = 0;
	int a  = 0;
	int b = 0;
	int c = 0;
	while(true){
		if(cot == 0){
			if(a == i.size()){
				cout << 'A' << endl;
				return 0;
			}
			if(i[a] == 'a') cot = 0;
			else if(i[a] == 'b') cot = 1;
			else if(i[a] == 'c') cot = 2;
			a++;
		} else if(cot == 1){	
			if(b == j.size()){
				cout << 'B' << endl;
				return 0;
			}
			if(j[b] == 'a') cot = 0;
			else if(j[b] == 'b') cot = 1;
			else if(j[b] == 'c') cot = 2;
			b++;
		} else if(cot == 2){
			if(c == n.size()){
				cout << 'C' << endl;
				return 0;
			}
			if(n[c] == 'a') cot = 0;
			else if(n[c] == 'b') cot = 1;
			else if(n[c] == 'c') cot = 2;
			c++;
		}
	}
	return 0;
}


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

typedef __int128 lll;
typedef pair<lll, int> st; 
const int maxn = 100, mod = 998244353;
int n, a[maxn + 3][maxn + 3], b[maxn + 3], c[maxn + 3][maxn + 3];
char s[maxn + 3];
map<st, int> dp;

st encode(int a[], int n) {
	st ret = make_pair(0, n);
	for (int i = 1; i <= n; i++) {
		ret.first = ret.first << 1 | a[i];
	}
	return ret;
}

int solve(st x, int dep = 0) {
	if (dp.count(x)) {
		return dp[x];
	}
	if (x.second == 0) {
		return 1;
	}
	int &ret = dp[x];
	lll tmp = x.first;
	int len = x.second;
	for (int i = len; i; i--) {
		a[dep][i] = tmp & 1, tmp >>= 1;
	}
	for (int i = 1; i < len; i++) {
		b[i] = a[dep][i + 1];
	}
	st s = encode(b, len - 1);
	ret = 1ll * (a[dep][1] + 1) * solve(s, dep + 1) % mod;
	for (int i = 1; i <= len >> 1; i++) {
		for (int k = 1; k <= i; k++) {
			c[dep][k] = a[dep][k];
		}
		for (int j = 2; i * j <= len; j++) {
			int tot = i * j;
			for (int k = 1; k <= len - tot; k++) {
				b[k] = a[dep][tot + k];
			}
			s = encode(b, len - tot);
			int p = solve(s, dep + 1);
			for (int k = 1; k <= i; k++) {
				c[dep][k] &= a[dep][(j - 1) * i + k];
			}
			s = encode(c[dep], i);
			int q = solve(s, dep + 1);
			ret = (ret + 1ll * p * q) % mod;
		}
	}
	return ret;
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	lll msk = 0;
	for (int i = 1; i <= n; i++) {
		msk = msk << 1 | (s[i] ^ '0');
	}
	printf("%d\n", solve(make_pair(msk, n)));
	return 0;
}

Measured memory_bytes: 4608
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define MAXN 1000
long long N,M,C[MAXN+5][5],Ans;
int main(){
	scanf("%lld %lld",&N,&M);
	for(long long i=1;i<=N;i++)
		for(long long j=1;j<=3;j++)
			scanf("%lld",&C[i][j]);
	for(long long i=0;i<8;i++){
		vector <long long> vec;
		for(long long j=1;j<=N;j++){
			long long S=0;
			for(long long k=1;k<=3;k++)
				if((i&(1<<(k-1)))>0) S+=C[j][k];
				else S-=C[j][k];
			vec.push_back(S);
		}
		sort(vec.begin(),vec.end());
		long long A=0;
		for(long long i=1;i<=M;i++)
			A+=vec[vec.size()-i];
		Ans=max(Ans,A);			
	}
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

long long int wari(long long int pre, long long int now) {
	long long int x = pre / now;
	if (pre%now)return ++x;
	return x;
}

int main() {
	int n;
	cin >> n;
	long long int pre_a = 0, pre_b = 0;
	for (int i = 0; i < n; i++) {
		long long int a, b;
		cin >> a >> b;
		if (pre_a <= a && pre_b <= b) {
			pre_a = a; pre_b = b;
		}
		else {
			long long int c = max(wari(pre_a, a), wari(pre_b, b));
			pre_a = a*c; pre_b = b*c;
		}
	}
	cout << pre_a + pre_b << endl;
	return 0;
}


Measured memory_bytes: 384
let to_array s = Str.split (Str.regexp_string " ") s
                 |> List.map float_of_string
                 |> Array.of_list;;

let () =
  let n = read_int () in
  let rec read = function
    0 -> ()
    | i ->
       let l = read_line () |> to_array in
       let (x1,y1,x2,y2,x3,y3,x4,y4) = (l.(0),l.(1),l.(2),l.(3),l.(4),l.(5),l.(6),l.(7)) in
       let a = y2 -. y1 and b = x1 -. x2 and e = x1*.y2 -. x2 *. y1 and
           c = y4 -. y3 and d = x3 -. x4 and f = x3*.y4 -. x4 *. y3 in
       let adbc = a *. d -. b *. c and s = e *. d -. b *. f and t = a *. f -. e *. c in
       let x = s/.adbc and y = t/.adbc and
           f z = if z = -0.0 then 0.0 else z in
       Printf.printf "%.10f %.10f\n" (f x) (f y);
       read (i-1)
  in read n;;

Measured memory_bytes: 4460
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class AGC_021_B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var xys = new int[n][];
            for(int i = 0; i < n; i++)
            {
                xys[i] = ReadInts();
            }

            for(int i = 0; i < n; i++)
            {
                var rads = new double[n - 1];
                for (int j = 0; j < n; j++)
                {
                    if (i == j) continue;
                    double x = xys[j][0] - xys[i][0];
                    double y = xys[j][1] - xys[i][1];
                    double rad = Math.Atan2(y, x);
                    rad += Math.PI / 2;
                    if (rad < 0) rad += Math.PI * 2;
                    if (j > i)
                    {
                        rads[j - 1] = rad;
                    }
                    else
                    {
                        rads[j] = rad;
                    }
                }
                if (rads.Length == 1)
                {
                    Console.WriteLine(0.5);
                    continue;
                }

                Array.Sort(rads);
                double r = 0;
                for(int j = 0; j < n - 1; j++)
                {
                    int kk = (j + n - 2) % (n - 1);
                    while (rads[kk] == rads[j] && j != kk)
                    {
                        kk += (n - 2);
                        kk %= (n - 1);
                    }
                    double delta = rads[kk] - rads[j];
                    if (delta < 0) delta += Math.PI*2;
                    if (delta < Math.PI) r = Math.Max(r, Math.PI - delta);
                }
                Console.WriteLine(r / Math.PI / 2);
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11476
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<vector<int>> inp;
vector<int> dp;

void graph_dp(int i)
{
    int ans=0;
    for(auto ele:inp[i])
    {
        if(dp[ele] == -1) graph_dp(ele);
        ans = max(ans,1 + dp[ele]);
    }
    dp[i] = ans;
}  

int driver()
{
    dp.assign(n,-1);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(dp[i] == -1) graph_dp(i);
        ans = max(ans,dp[i]);
    }
    return ans;
}

 

int main()
{
    /*ifstream cinp;
    cinp.open("input.txt");
    ofstream coutp;
    coutp.open("output.txt");
*/
    //ios_base::sync_with_stdio(0); 
    //cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin>>n>>m;
    inp.resize(n);

    for(int i=0;i<m;i++)
    {
        int a, b;
        cin>>a>>b;
        inp[--a].push_back(--b);
    }
    
    cout<<driver()<<"\n";
}


Measured memory_bytes: 11028
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;


long long dp[2][100010];

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

    // init
    for (int i=0; i<2; i++) {
        for (int j=0; j<100010; j++) {
            dp[i][j] = LLONG_MIN / 3;
        }
    }

    vector<long long> v;
    for (int i=0; i<N; i++) {
        long long a; cin >> a;
        v.push_back(a);
    }

    dp[0][0] = 0;
    for (int i=1; i<N; i++) {  // 1base
        long long A = v[i-1];

        // v[i]を反転させない
        dp[0][i] = max(dp[0][i], dp[0][i-1] + A);
        dp[0][i] = max(dp[0][i], dp[1][i-1] - A);

        // v[i]を反転させる
        dp[1][i] = max(dp[1][i], dp[0][i-1] - A);
        dp[1][i] = max(dp[1][i], dp[1][i-1] + A);
    }

    long long a = dp[0][N-1] + v[N-1];
    long long b = dp[1][N-1] - v[N-1];
    cout << max(a,b) << endl;


    return 0;
}

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

int main()
{
        ll N, K; cin >> N >> K;
        vector<ll> p(N, 0);
        rep(i, N) {
                cin >> p[i];
        }
        sort(p.begin(), p.end());
        ll ans = 0;
        rep (i, K) {
                ans += p[i];
        }
        cout << ans << endl;


}


Measured memory_bytes: 3636
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  long n, a, b;
  readf (" %d %d %d", &n, &a, &b);
  long res;
  long s = a + b;
  long u = n / s;
  long v = n % s;
  res += min (v, a);
  res += u * a;
  writeln (res);
}



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

int main()
{
	int H, W, Ch, Cw, Dh, Dw;
	cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
	Ch--;
	Cw--;
	Dh--;
	Dw--;
	vector<string> S( H );
	for( int i = 0; i < H; i++ ) {
		cin >> S[i];
	}

	typedef tuple<int, int, int> T;
	const int INF = INT32_MAX / 2;
	vector<vector<int>> dist( H, vector<int>( W, INF ) );
	dist[Ch][Cw] = 0;
	deque<T> que;
	que.push_front( T( 0, Ch, Cw ) );
	int dirv[4] = { 1, -1, 0, 0 };
	int dirh[4] = { 0, 0, 1, -1 };
	while( !que.empty() ) {
		int d, y, x;
		tie( d, y, x ) = que.front();
		que.pop_front();
		if( dist[y][x] < d ) continue;
		if( y == Dh && x == Dw ) break;
		for( int i = 0; i < 4; i++ ) {
			int ny = y + dirv[i];
			int nx = x + dirh[i];
			if( ny < 0 || ny >= H || nx < 0 || nx >= W ) continue;
			if( S[ny][nx] == '#' ) continue;
			if( dist[ny][nx] > d ) {
				que.push_front( T( d, ny, nx ) );
				dist[ny][nx] = d;
			}
		}
		int sty = y - 2;
		int endy = y + 2;
		int stx = x - 2;
		int endx = x + 2;
		for( int i = sty; i <= endy; i++ ) {
			for( int j = stx; j <= endx; j++ ) {
				if( i < 0 || i >= H || j < 0 || j >= W ) continue;
				if( S[i][j] == '#' ) continue;
				if( dist[i][j] > d + 1 ) {
					que.push_back( T( d + 1, i, j ) );
					dist[i][j] = d + 1;
				}
			}
		}
	}
	int ans = dist[Dh][Dw];
	if( ans == INF ) ans = -1;

	cout << ans << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n;
  cin >> n;
  vector<P> v(n);
  REP(i,n){
    I a;
    cin >> a;
    v.at(i).first = a;
    v.at(i).second = i;
  }
  SORT(v);
  REP(i,n){
    if (i != n-1){
      cout << v.at(i).second + 1 << " ";
    }else{
      cout << v.at(i).second + 1 << endl;
    }
  }
  return 0;
}



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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long N, std::vector<long long> a){
    lli cnt=0;

    bool all = true;
    REP(i,0,N){
        while(a[i]%2==0){
            cnt++;
            a[i]/=2;
        }
    }
    cout<<cnt<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

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


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

using namespace std;

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

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

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

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

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

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

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

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i], v[i]--;

    vector<ll> a(n), b(n);
    for (ll t = 0; t < n; t++) a[t] = (t + 1) * n;
    for (ll t = 0; t < n; t++) b[t] = n * n - t * n;

    rep(i, n) {
        a[v[i]] += i;
    }
    for (ll l : a) cout << l << ' ';
    cout << endl;
    for (ll l : b) cout << l << ' ';
    cout << endl;

    cout << endl;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
string a,b;
int shu=0x3f3f3f3f; 
int main()
{
	cin>>a>>b;
	for(int i=0;i<a.size()-b.size()+1;i++)
	{
		int ans=0;
		for(int j=i;j<=i+b.size()-1;j++)
		{
			if(b[j-i]!=a[j]) ans++;
		}
		shu=min(ans,shu);
	 } 
	 cout<<shu<<endl; 
 } 

Measured memory_bytes: 3640
n=int(input())
s="abcdefghij"
ans=[["a",1]]
def solve():
	for x in ans:
		if len(x[0])<n:
			for j in range(x[1]+1):
				if j<=x[1]-1:
					ans.append([x[0]+s[j],x[1]])
				else:
					ans.append([x[0]+s[j],x[1]+1])
solve()
ans.sort()
for x in ans:
	if len(x[0])==n:
		print(x[0])


Measured memory_bytes: 27940
#include<bits/stdc++.h>
#define lli long long int;
using namespace std;

int getint(){
    int n;
    scanf("%d",&n);
    return n;
}

int main(void){
    int N=getint();
    for(int i=1;i<=N;i++){
      if((i+1)*i/2>=N){
        cout<<i<<endl;
        return 0;
      }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	int r, g;
	string e;
	cin >> r >> e;
	g = r / 2;
	if (r % 2 == 0) {
		for (int i = 0; i < g; i++) {

			if (e.at(i) != e.at(i + g)) {
                cout << "No" << endl;
				return 0;
			}

		}
        
        cout << "Yes" << endl;

	}
	else {
		cout << "No" << endl;
	}
    return 0;
}


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

int main(){
  ll N;
  map<ll,ll> A;
  cin >> N;
  rep(i,N){
    A[i+1] = 0;
  }
  rep(i,N-1){
    int t;
    cin >> t;
    ++A[t];
  }
  rep(i,N){
    cout << A[i+1] << endl;
  }
}

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

int main() {
  string S;
  cin >> S;
  int length = S.size();
  length /= 2;
  int ans = -1;

  rep(i,S.size()/2 - 1) {
    --length;
    rep(i,length) {
      if (S[i] != S[i+length]) break;
      if (i == length-1) ans = length*2;
    }
    if (ans != -1) break;
  }

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define repi(i,a,b) for(lint i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif

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

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

    lint n,m;cin>>n>>m;
    co((n-1)*(m-1));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<long long>().max()

int main() {

	 long long mod = 1e9+7;
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n+1, 0);
    for(long long i=1; i<=n; i++) {
        cin >> a[i];
    }
    vector<vector<long long>> opt(n+1, vector<long long>(k+1));
    opt[0][0] = 1;
    
    vector<vector<long long>> prefix(n+1, vector<long long>(k+1));
    for(long long j=0; j<=k; j++) {
        prefix[0][j] = 1;
	 }

	 for(long long i=1;i<=n;i++) {

		 prefix[i-1][0] = 1;
		 for(int j=1; j<=k; j++) {
			 prefix[i-1][j] = (prefix[i-1][j-1] + opt[i-1][j]) % mod;
		 }

		 for(int j=0; j<=k; j++) {
			 if (j>a[i]) opt[i][j] = (prefix[i-1][j] - prefix[i-1][j-a[i]-1]+mod) % mod;
			 else opt[i][j] = prefix[i-1][j];
		 }
	 }

    cout << opt[n][k] << endl;
    
}





Measured memory_bytes: 161468
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]

def route(l):
  routeout = []
  if l[0] > 0:
    if sc[l[1]][l[0]-1] == '.':
      routeout.append([l[0]-1, l[1]])
  if l[0] < w-1:
    if sc[l[1]][l[0]+1] == '.':
      routeout.append([l[0]+1, l[1]])
  if l[1] > 0:
    if sc[l[1]-1][l[0]] == '.':
      routeout.append([l[0], l[1]-1])
  if l[1] < h-1:
    if sc[l[1]+1][l[0]] == '.':
      routeout.append([l[0], l[1]+1])
  return routeout

def f(linl, out):
  nextxy = []
  for l in linl:
    nextxy += route(l)
    for ll in route(l):
      sc[ll[1]][ll[0]] = '#'
  if len(nextxy)>0:
    return f(nextxy, out+1)
  else:
    return out
  
r = set()
for i in range(h):
  for j in range(w):
    if s[i][j] == '.':
      sc = [[l for l in ll] for ll in s]
      sc[i][j] = '#'
      r.add(f([[j, i]], 0))
print(max(r))

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX 200000

int main (){
int R[MAX],n,i;
int minv;
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&R[i]);
int maxv=-2000000000;
minv=R[0];

for(i=1;i<n;i++){
maxv =  fmax(maxv,R[i]-minv);
minv = fmin(minv,R[i]);
}

printf("%d\n",maxv);
return 0;
}



Measured memory_bytes: 2584
#include <iostream>
#include <vector>
using namespace std;
vector<int> e[100005];
int p,q,vis[100005];
void dfs(int u)
{
 vis[u]=1;
 for(auto v:e[u])
  if(vis[v]==-1)
  {
   if(p)q=v;
   else p=v;
  }
  else if(!vis[v])dfs(v);
}
int main()
{
 ios::sync_with_stdio(false);
 int n,m;
 cin>>n>>m;
 for(int i=1;i<=m;i++)
 {
  int u,v;
  cin>>u>>v;
  e[u].push_back(v);
  e[v].push_back(u);
 }
 int maxd=0,cnt=0;
 for(int i=1;i<=n;i++)
 {
  int t=e[i].size();
  if(t%2)
  {
   cout<<"No"<<endl;
   return 0;
  }
  if(t>maxd)
   maxd=t,cnt=1;
  else if(t==maxd)cnt++;
 }
 if(maxd>=6)
  cout<<"Yes"<<endl;
 else if(maxd==4)
 {
  if(cnt>=3)
   cout<<"Yes"<<endl;
  else if(cnt==1)
   cout<<"No"<<endl;
  else
  {
   for(int i=1;i<=n;i++)
    if(e[i].size()==4)vis[i]=-1;
   for(int i=1;i<=n;i++)
    if(!vis[i])
    {
     p=q=0;
     dfs(i);
     if(p==q)
     {
      cout<<"Yes"<<endl;
      return 0;
     }
    }
   cout<<"No"<<endl;
  }
 }
 else cout<<"No"<<endl;
 return 0;
}

Measured memory_bytes: 6912