akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    int a;
    vector<ll> B(n+1);
    for(int i=1;i<=n;i++){
        cin>>a;
        B[i] = a-i;
    }
    sort(B.begin()+1,B.end());
    
    ll b = B[(n+1)/2];
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans += abs(B[i]-b);
    }
    cout<<ans<<endl;
}

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

int main() {
    int n, w;
    cin >> n >> w;
    vector<int> min_weight(n * 100 + 1, w + 1);
    min_weight[0] = 0;
    
    for (auto i = 0; i < n; ++i) {
        int value, weight;
        cin >> value >> weight;
        for (auto value_index = min_weight.size() - 1; value_index >= value; --value_index) {
            if (min_weight[value_index] > min_weight[value_index - value] + weight) {
                min_weight[value_index] = min_weight[value_index - value] + weight;
            }
        }
    }
    for (int value_index = min_weight.size()-1; value_index >= 0; --value_index) {
        if (min_weight[value_index] <= w) {
            cout << value_index << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3132
#include <iostream>
#include <stdio.h>
#include <math.h>

#define M_PI 3.141592653589793

int main()
{
	double a, b, c;
	scanf("%lf %lf %lf", &a, &b, &c);

	c = M_PI * c / 180;

	double area = a * b * sin(c) / 2;

	double len = sqrt(pow(a, 2) + pow(b, 2) - 2 * a*b*cos(c));

	double height = area * 2 / a;

	printf("%lf\n", area);
	printf("%lf\n", len + a + b);
	printf("%lf\n", height);

}


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

int main() {
  int N;
  vector<int> a, n;

  cin >> N;
  n.resize(N, 0);

  int tmp;
  rep(i,N) {
    cin >> tmp;
    a.push_back(tmp);
    n[tmp-1]++;
  }
  
  ll sum = 0;
  rep(i,N) {
    sum += (ll)n[i] * (n[i] - 1) / 2;
  }
  rep(i,N) {
    ll sum2 = sum;
    int tmp = a[i] - 1;
    if (n[tmp] > 1) {
      sum2 -= (ll)n[tmp] * (n[tmp] - 1) / 2;
      sum2 += (ll)(n[tmp] - 1) * (n[tmp] - 2) / 2;
    }
    cout << sum2 << endl;
  }

  return 0;
}


Measured memory_bytes: 4340
#include<iostream>
#include<iomanip>

using namespace std;
using ll=long long;

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

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b,c;
  cin>>a>>b>>c;
  a<=c && c<=b ? cout<<"Yes"<<endl :cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,k,i;
    cin>>n;
    string s;
    cin>>s;
    cin>>k;
    for (i=0;i<n;i++)
    {
        if (s[i]!=s[k-1])
            cout<<'*';
        else
            cout<<s[i];
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A ,B;
  string S, T, U;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if(U == S)
    A--;
  else
    B--;
  
  cout << A << ' ' << B << endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ll a,b,c,k;
   cin>>a>>b>>c>>k;
   if(k<=a)
        cout<<k;
   else if(k<=a+b)
        cout<<a;
   else cout<<a-(k-a-b);        
   
   return 0;        
}  
  
   

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main()
{
    int n;
    long long a;
    long long minValue = 1000000;
    long long maxValue = -1000000;
    long long sum = 0;

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (a < minValue)
            minValue = a;
        if (a > maxValue)
            maxValue = a;
        sum += a;
    }

    cout << minValue << " " << maxValue << " " << sum << endl;

    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

bool water[6000], sugar[6000];

int main(void) {
    int i, j, a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    water[0] = sugar[0] = true;
    REP (i,f) {
        water[i + a * 100] |= water[i];
        water[i + b * 100] |= water[i];
        sugar[i + c] |= sugar[i];
        sugar[i + d] |= sugar[i];
    }

    pair<int,int> ans = {a * 100,0};
    for (i = 100; i <= f; i += 100) if (water[i]) {
        for (j = 0; j <= e * (i / 100) && j <= f - i; j++) if (sugar[j]) {
            if (ans.second * (i+j) < ans.first * j) {
                ans = {i+j,j};
            }
        }
    }
    cout << ans.first << ' ' << ans.second << endl;
    return 0;
}

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

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


Measured memory_bytes: 256
n = int(input())
for i in range(1,n+1):
    if i % 3 == 0:
        print("",i,end="")
    else:
        num = i
        while num != 0:
            if num % 10 == 3:
                print("",i,end="")
                break
            else:
                num //= 10
print()


Measured memory_bytes: 6160
#include <stdio.h>
int main(void)
{
  int n,k,ans=0;
  scanf("%d%d",&n,&k);
  int h[n];
  for(int i = 0; i < n; ++i){
    scanf("%d",&h[i]);
    if(h[i] >= k) ++ans;
  }
  printf("%d\n",ans);
  return 0;
}

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

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

#define MOD(x, y) ((x) % (y))
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))
#define DIVFLOOR(x, y) (((x) + ((y) / 2)) / (y))
#define DIVROUND(x, y) ((x) - MOD(x, y) >= MOD(x, y) ? DIVCEIL(x, y) : DIVFLOOR(x, y))

constexpr int MAX_N = 1e5 + 7;

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

  long double win{};
  int ritsu{1};
  int all{N};

  do {
    if (N >= K) {
      win += ((N - K + 1.0) / all) / ritsu;
      N = K - 1;
    }
    K = DIVCEIL(K, 2);
    ritsu *= 2;
  } while (N >= 1);

  cout << std::setprecision(12) << win << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 vector<char> S(10);
int sum=0;
for(int i=0; i<4; i++) cin>>S.at(i);
for(int i=0; i<4; i++){
      if(S.at(i)=='+'){
              sum++;
           } else if(S.at(i)=='-'){
           sum--;
            }
}
cout<<sum<<endl;

  }
               
            
     




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    string ans = "No";
    if (abs(a-c)<=d) ans = "Yes";
    if (abs(a-b)<=d && abs(b-c)<=d) ans = "Yes";
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def go(human): #1:left,2:pro,3:right,4;back
    if human[2]==0: #human's direction is east
        if(human[1]*2-1>=0 and wall[human[1]*2-1][human[0]]=='1'):
            return 3
        elif (human[0]<=3 and wall[human[1]*2][human[0]]=='1'):
            return 0
        elif (human[1]*2+1<=8 and wall[human[1]*2+1][human[0]]=='1'):
            return 1
        else:
            return 2
    if human[2]==1: #south
        if(human[0]<=3 and wall[human[1]*2][human[0]]=='1'):
            return 3
        elif (human[1]*2+1<=8 and wall[human[1]*2+1][human[0]]=='1'):
            return 0
        elif (human[0]-1>=0 and wall[human[1]*2][human[0]-1]=='1'):
            return 1
        else:
            return 2
    if human[2]==2: #west
        if(human[1]*2+1<=8 and wall[human[1]*2+1][human[0]]=='1'):
            return 3
        elif (human[0]-1>=0 and wall[human[1]*2][human[0]-1]=='1'):
            return 0
        elif (human[1]*2-1>=0 and wall[human[1]*2-1][human[0]]=='1'):
            return 1
        else:
            return 2
    if human[2]==3: #north
        if(human[0]-1>=0 and wall[human[1]*2][human[0]-1]=='1'):
            return 3
        elif (human[1]*2-1>=0 and wall[human[1]*2-1][human[0]]=='1'):
            return 0
        elif (human[0]<=3 and wall[human[1]*2][human[0]]=='1'):
            return 1
        else:
            return 2

        # if human[2]==0:
        #     if(wall[0][human[0]]==1):
        #         return 2
        #     elif(wall[1][human[0]]==1):
        #         return 3
        #     else:
        #         return 4
        # elif human[2]==8:
        #     if (wall[7][human[0]]==1):
        #         return 2
        #     elif()
wall=[]
while True:
    try:
        for i in range(9):
            wall.append(raw_input())
    except:
        break

solve="R"
human=(1,0,0)
while human[0]!=0 or human[1]!=0:
    direction=(human[2]+go(human))%4
    if direction == 0:
        human=(human[0]+1,human[1],direction)
        solve+="R"
    elif direction == 1:
        human=(human[0],human[1]+1,direction)
        solve+="D"
    elif direction == 2:
        human=(human[0]-1,human[1],direction)
        solve+="L"
    else:
        human=(human[0],human[1]-1,direction)
        solve+="U"
print solve

Measured memory_bytes: 4408
import heapq
import math

n, m = map(int, input().split())
a = [-1 * int(i) for i in input().split()]
heapq.heapify(a)
for _ in range(m):
    b = heapq.heappop(a)
    heapq.heappush(a, math.ceil(b / 2))
print(-1 * sum(a))

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

static const int NMAX=50000;
static const int INFTY=(1<<29);
int c[21];
int t[NMAX+1];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>c[i];
    }
    for(int i=0;i<=NMAX;i++)t[i]=INFTY;
    t[0]=0;
    for(int i=0;i<m;i++)
    {
        for(int j=0;j+c[i]<=n;j++)
            t[j+c[i]]=min(t[j+c[i]],t[j]+1);
    }
    cout<<t[n]<<endl;
}


Measured memory_bytes: 3300
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;



bool comp(const string& a, const string& b) {
	if (a.compare(b) <= 0) return true;
	return false;
}

int main() {
	int n, l; cin >> n >> l;
	vector<string> str;
	for (int i = 0; i < n; i++) {
		string work;  cin >> work;
		str.push_back(work);
	}

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

	for (int i = 1; i < n; i++) {
		str.at(0) += str.at(i);
	}
	cout << str.at(0) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int i, j=0;

	for (i = 1; i <= 9; i++)
	{
		for (j = 1; j <= 9; j++)
{			
 printf("%dx%d=%d\n",i,j, (i*j));
}
		
	}
	return 0;
}

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

int N;

void solve() {
  int A[N] = {};
  int count[N] = {};
  int ans = 100000;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    while(A[i] % 2 == 0){
      A[i] = A[i] / 2;
      count[i]++;
    }
    if (ans > count[i]){
      ans = count[i];
    }
  }
  cout << ans << endl;
}

int main() {
  cin >> N;
  solve();
  return 0;
}

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

int main() {
  int n,k;string s;
  cin >> n >> k >> s;
  if(s[k-1] == 'A') s[k-1] = 'a';
  else if(s[k-1] == 'B') s[k-1] = 'b';
  else s[k-1] = 'c';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let n = sc.value::<i64>();
    let a = sc.array::<i64>(n as usize);

    let ans = a.iter().sum::<i64>() - n;

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


Measured memory_bytes: 4352
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}



fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let (_, a, b): (usize, usize, usize) = (sc.read(), sc.read(), sc.read());
    let s = max(a, b) - min(a, b);
    if s % 2 == 0 {
        println!("Alice");
    } else {
        println!("Borys");
    }
}

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

int n, m;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	vector<int> v(m, 0);
	for(int i=0; i<n; ++i){
		int k = 0;
		cin >> k;
		for(int j=0; j<k; ++j){
			int a;
			cin >> a;
			++v[a-1];
		}
	}
	int ans = 0;
	for(int i=0; i<m; ++i)
		if(v[i] == n)
			++ans;
	cout << ans << "\n";
}

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

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

ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	ll ans=a.at(0);
	rep(i,n-1){
		ans=lcm(ans,a.at(i+1));
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(),x.end()
#define TESTCASES 0
using namespace std;

int s, w;

int Go() {

  scanf("%d %d", &s, &w);

  puts(s <= w ? "unsafe" : "safe");

  return 0;
}


int main() {


  int t;
  if (TESTCASES) scanf("%d", &t);
  else           t = 1;

  while (t--) Go();
}

Measured memory_bytes: 3660
#include <stdio.h>

#define N 200000

int main(){
    int n, i, j, tmp, num[N], max=-999999999, a;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &num[i]);
    }
    
     for (j = n - 1; j >= 0; j--) {
        if (num[j] < max) continue;
        for (i = j - 1; i >= 0; i--) {
            tmp = num[j] - num[i];
            max = max < tmp ? tmp : max;
        }
    } 
    
    printf("%d\n", max);
    
    return 0;
}




Measured memory_bytes: 2520
def nCr(n, r):
    mod=10**9+7
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

x,y=map(int,input().split())
f=(x+y)//3
m=-(1/3)*x+(2/3)*y
n=f-m
if (x+y)%3 or n<0 or m<0:
   print(0)
   exit()

print(nCr(int(f),int(n)))

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
int main(){
    unordered_map<int,int>p;
    int n;
    cin>>n;
    int a[n];
    for(int i=2;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        p[i]=0;
    }
    for(int i=2;i<=n;i++){
        p[a[i]]++;
    }for(int i=1;i<=n;i++){
        cout<<p[i]<<endl;
    }
}

Measured memory_bytes: 12196
#include <stdio.h>
#include <math.h>
#define PI 3.14159265359
typedef struct{
  double x,y;
}P;//Point
void Koch(int ,P ,P );
double radian=PI/3;//60degrees

int main(void){
  int n;
  P p1={0,0},p2={100,0};
  scanf("%d",&n);
  printf("%.8f %.8f\n",0.0,0.0);
  Koch(n,p1,p2);
  printf("%.8f %.8f\n",100.0,0.0);
  return 0;
}

void Koch(int n,P left,P right){
  P s,t,u;
  if(n==0)return ;
  s.x=(2*left.x+right.x)/3;
  s.y=(2*left.y+right.y)/3;
  t.x=(left.x+2*right.x)/3;
  t.y=(left.y+2*right.y)/3;
  u.x=(t.x-s.x)*cos(radian)-(t.y-s.y)*sin(radian)+s.x;
  u.y=(t.x-s.x)*sin(radian)+(t.y-s.y)*cos(radian)+s.y;
  Koch(n-1,left,s);
  printf("%.8f %.8f\n",s.x,s.y);
  Koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  Koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  Koch(n-1,t,right);
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t k,q,r,n=50,i;
  cin>>k;
  q=k/n;
  r=k%n;
  cout<<n<<endl;
  for(i=0;i<n;i++){
    if(i>0) cout<<' ';
    if(i<50-r) cout<<n-1+q-r;
    else cout<<2*n+q-r;
  }
  cout<<endl;
}

Measured memory_bytes: 3572
#include<iostream>
#include<set>
using namespace std;
int main()
{
    set<long long int>a;
    long long int n,s,i,x;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        a.insert(x);

    }
    s=a.size();
    if(n==s)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }

}


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

int main(){
    int n,l;
    cin >> n >> l;
    int origin = (l-1)*n + (n*(n+1))/2;
    int eaten;
    if (l > 0){
        eaten = l;
    }else if (l > 1 - n && l <= 0){
        eaten = 0;
    }else{
        eaten = l + n - 1;
    }
    

    cout << origin - eaten << endl;
}

Measured memory_bytes: 256
//Author : hardRock
//Problem Link :

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
//#include <bits/stdc++.h>

using namespace std;


int main() {

    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);

	int T;
	cin >> T;

	cout << ((T < 1200) ? "ABC" : "ARC") << endl;

	//system("pause");
    return 0;
}










Measured memory_bytes: 256
#include<stdio.h>
#define mod 1000000007
#define are(h,i,j) (dp[(h)-1][i][j]+a[i][h-(i)]+a[j][h-(j)])
int max(int a,int b){
	if(a>b){ return a; } else{return b;}
}
int main(void){
	//定数倍ひどいことになってるなこれ
	int H,W,h,i,j,b;
	static int a[401][401]={0};
	static int dp[401][401][401]={0};
	scanf("%d %d",&H,&W);
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			scanf("%d",&b);
			a[i][j]=b;
		}
	}
	dp[0][1][1]=a[0][0];
	for(h=1;h<=H+W;h++){
		for(i=1;i<=h;i++){
			for(j=i+1;j<=h+1;j++){//i<j
				dp[h][i][j]=max(max(dp[h-1][i][j],dp[h-1][i-1][j]),max(dp[h-1][i][j-1],dp[h-1][i-1][j-1]));
				dp[h][i][j]+=a[i-1][h-(i-1)]+a[j-1][h-(j-1)];
			}
		}
	}
	printf("%d\n",dp[H+W][H][H+1]);
	return 0;
}

Measured memory_bytes: 250368
#include <bits/stdc++.h>
using namespace std;
using f32 = float;
using f64 = double;
using LL = long long;
using ULL = unsigned long long;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
int main()
{ 
 double n;
  cin >> n;
  cout <<ceil(n/2);
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    input = input.split('\n').map(v => parseInt(v))
    const a = input[0]
    const b = input[1]
    const h = input[2]
    console.log((a + b) * h / 2)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
var
	a,z,i:Longint;
	s:String;
begin
	readln(s);
	for i:=1 to length(s) do begin
		if (a=0)and(s[i]='A')then a:=i;
		if s[i]='Z' then z:=i;
	end;
	write(z-a+1)
end.


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int
vector<int> e[100005];
void solve(long long N, long long M, std::vector<long long> H,
           std::vector<long long> A, std::vector<long long> B) {
  rep(i, M) e[A[i] - 1].push_back(B[i] - 1);
  rep(i, M) e[B[i] - 1].push_back(A[i] - 1);
  int ret = 0;
  rep(i, N) {
    bool l = true;
    for (auto s : e[i]) {
      if (H[i] <= H[s])
        l = false;
    }
    if (l)
      ret++;
  }
  cout << ret << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &H[i]);
  }
  std::vector<long long> A(M);
  std::vector<long long> B(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, M, std::move(H), std::move(A), std::move(B));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 11468
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var a = s.ToCharArray();
        var ans1 = getAns0(a);
        var ans2 = getAns1(a);
        var ans = Min(ans1, ans2);
        Console.WriteLine(ans);
    }
    static int getAns1 (char[] a)
    {
        var count = 0;
        var aL = a.Length;
        var p = 0;
        while (true)
        {
            if (a[p] == '0') count++;
            p++;
            if (p == aL) break;
            if (a[p] == '1') count++;
            p++;
            if (p == aL) break;
        }
        return count;
    }
    static int getAns0(char[] a)
    {
        var count = 0;
        var aL = a.Length;
        var p = 0;
        while (true)
        {
            if (a[p] == '1') count++;
            p++;
            if (p == aL) break;
            if (a[p] == '0') count++;
            p++;
            if (p == aL) break;
        }
        return count;
    }
}

Measured memory_bytes: 13536
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<int> A(n + 1, 0), B(n + 1, 0);
    cin >> A[1];
    for(int i = 2; i <= n; i++) {
        int a;
        cin >> a;
        A[i] = A[i - 1] + a;
    } 
    cin >> B[1];
    for(int i = 2; i <= n; i++) {
        int b;
        cin >> b;
        B[i] = B[i - 1] + b;
    } 
    int ans = -1;
    rrep(i, n) {
        int value;
        value = A[i] + (B[n] - B[i - 1]);
        ans = max(ans, value);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

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

ll a[MAX_N];

int main() {

  ll N, x;
  cin >> N >> x;
  rep(i, N) cin >> a[i];

  ll res = 0;

  rep(i, N-1) {
    ll y = a[i]+a[i+1];
    if(y>x) {
      if(y-x<=a[i+1]) {
        a[i+1] -= y-x;
        res += y-x;
      }else {
        a[i+1] = 0;
        a[i] -= (y-x-a[i+1]);
        res += y-x;
      }
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1024
//
// Created by kashi on 17-05-2020.
//
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define Endl endl

int main() {
    int k;
    cin>>k;
    string str;
    cin>>str;
    int size=str.size();
    if(size<=k){
        cout<<str<<endl;
        return 0;
    }
    else{
        str.erase(str.begin()+k,str.end());
        cout<<str<<"..."<<endl;
        return 0;
    }

}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int n;cin >> n;
    string s,t;cin >> s >> t;
    for(int i=0;i<n;i++){
        cout << s[i];
        cout << t[i];
    }
    cout << endl;
    return 0;
}

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

int main(void){
  int a, ans = 0, cp = 1;
  cin >> a;
  for(int i = 0; i < 3; i++){
    cp *= a;
    ans += cp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
n,m,c=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
ans=0
for _ in range(n):
    ai=[int(x) for x in input().split()]
    if sum([ai[i]*b[i] for i in range(m)])+c>0:
        ans+=1
print(ans)

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

int main()
{
    int n;
    cin >> n;
    
    const int limit = 1e5;
    
    vector<int> element(limit + 1, 0);
    for(int i = 1; i <= n; ++i)
    {
        int x;
        cin >> x;
        element[x]++;
    }
    
    int big = 0;
    for(int i = 1; i <= limit; ++i)
    {
        int bug = element[i - 1] + element[i] + element[i + 1];
        big = max(big, bug);
    }
    
    cout << big << endl;
    
    return 0;
}

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

string substring(string text, int low, int digit){
    string output = "";
    for(int i = low; i < low + digit; i++){
        output.push_back(text[i]);
    }
    return output;
}

void coutput(bool output){
    if(output){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

int main(){
	string S;
	cin >> S;
	coutput(substring(S, 0, 4) == "YAKI");
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
  
int main(){
    int n,year,ope,bfmoney,tax,interest,max,get,tempmoney=0;
    double up_yatta,temp;
    
    cin >> n;
    for( int i = 0 ; i < n ; i++ ){
	max = 0;
	cin >> bfmoney;
	cin >> year >> ope;
  
	tempmoney = bfmoney;
	for( int j = 0 ; j < ope ; j++ ){
	    get = 0;temp = 0;
	    bfmoney = tempmoney;
	    cin >> interest >> up_yatta >> tax;
        
	    if( interest == 1 ){
		for( int k = 0 ; k < year ; k++ ){
		    get = up_yatta * bfmoney;
		    bfmoney += get - tax;
		}  
	    }
	    else{
		for( int k = 0 ; k < year ; k++ ){
		    temp = bfmoney * up_yatta;
		    get += temp;
		    bfmoney -= tax;
		}
      
		bfmoney += get;
	    }
	    if( max < bfmoney ) max = bfmoney;
	}       
	cout << max << endl;
    }
    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int a,b,c;
  cin >> a >> b >> c;
  if(a==b && b==c)cout << "Yes";
  else cout << "No";
}

/*



 */


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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

int f(int n){
	if(n==0) return 1;
	else return 10*f(n-1);
}

int main(){

	int n,k;
	while(1){

		cin >> n >> k;
		if(n==0 && k==0) break;

		vector<int>card(n);
		rep(i,n) cin >> card[i];

		if(k==2){
			vector<int>u;
			rep(i,n){
				rep(j,n){
				  if(i!=j){
					  vector<int>v;
					  if(card[i]/10!=0) v.push_back(card[i]/10);
					                    v.push_back(card[i]%10);
					  if(card[j]/10!=0) v.push_back(card[j]/10);
										v.push_back(card[j]%10);

					  int s=v.size(); int p=0;
					  rep(i,s) p+=v[i]*f(s-1-i);
					  u.push_back(p);
					  v.clear();
				   }
				}
			}

			sort(u.begin(),u.end());
			vector<int>::iterator it=unique(u.begin(),u.end());
			u.erase(it,u.end());

			cout << u.size() << endl;

			u.clear();
		}

		if(k==3){
			vector<int>u;
			rep(i,n){
				rep(j,n){
					rep(k,n){
				  if(i!=j && i!=k && j!=k){
					  vector<int>v;
					  if(card[i]/10!=0) v.push_back(card[i]/10);
					                    v.push_back(card[i]%10);
					  if(card[j]/10!=0) v.push_back(card[j]/10);
										v.push_back(card[j]%10);
					  if(card[k]/10!=0) v.push_back(card[k]/10);
										v.push_back(card[k]%10);

					  int s=v.size(); int p=0;
					  rep(i,s) p+=v[i]*f(s-1-i);
					  u.push_back(p);
					  v.clear();
				   }
				}
			}
		}
			sort(u.begin(),u.end());
			vector<int>::iterator it=unique(u.begin(),u.end());
			u.erase(it,u.end());

			cout << u.size() << endl;

			u.clear();
		}

		if(k==4){
			vector<int>u;
			rep(i,n){
				rep(j,n){
					rep(k,n){
						rep(l,n){
				  if(i!=j && i!=k && i!=l && j!=k && j!=l && k!=l){
					  vector<int>v;
					  if(card[i]/10!=0) v.push_back(card[i]/10);
					                    v.push_back(card[i]%10);
					  if(card[j]/10!=0) v.push_back(card[j]/10);
										v.push_back(card[j]%10);
					  if(card[k]/10!=0) v.push_back(card[k]/10);
										v.push_back(card[k]%10);
					  if(card[l]/10!=0) v.push_back(card[l]/10);
										v.push_back(card[l]%10);

					  int s=v.size(); int p=0;
					  rep(i,s) p+=v[i]*f(s-1-i);
					  u.push_back(p);
					  v.clear();
				   }
				}
			}
		}
	}
			sort(u.begin(),u.end());
			vector<int>::iterator it=unique(u.begin(),u.end());
			u.erase(it,u.end());

			cout << u.size() << endl;

			u.clear();
		}

	}

	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int dp[10100];
int dpdp[10100];
int tmp[10100];

int main(){
  int n, p;
  string s;
  cin >> n >> p >> s;

  if(10 % p == 0){
    ll ans = 0;
    rep(i, n){
      if((s[i]-'0') % p == 0){
        ans += i+1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  vector<int> d(n+1);
  d[0] = 0;
  int ten = 1;
  REP(i, 1, n){
    int r = ((s[n-i] - '0') * ten) % p;
    d[i] = (d[i-1] + r) % p;
    ten *= 10;
    ten %= p;
  }

  map<int, int> mp;
  ll ans = 0;
  REP(i, 0, n){
    ans += mp[d[i]]++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1668
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
    for j in range(B+1):
        k =(X-(500*i+100*j))/50
        if 0 <= k <= C:
            # print(500*i,100*j,50*k,'=',500*i+100*j+50*k)
            count += 1
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n)  RFOR(i,0,n)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
#define P pair<int,int>
#define PPi pair<P,int>
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int N,W;
	ll a,b,c,d,result=-INF;
	vector<vector<ll>> v(4);

	cin>>N>>W;
	cin>>a>>b; v[0].pb(b);
	REP(i,N-1){
		cin>>c>>d;
		v[c-a].pb(d);
	}
	
	REP(i,4){
		DVSORT(v[i]);
		FOR(j,1,v[i].size()) v[i][j]+=v[i][j-1]; //累積和を取ることで計算量を減らす
		v[i].insert(v[i].begin(),0);
	}
	

	REP(i,v[0].size()){
		REP(j,v[1].size()){
			REP(r,v[2].size()){
				REP(k,v[3].size()){
					ll weight=a*i+(a+1)*j+(a+2)*r+(a+3)*k;
					if(W<weight) break;
					else chmax(result,v[0][i]+v[1][j]+v[2][r]+v[3][k]);
				}
			}
		}
	}
	print(result);
	return 0;
}




Measured memory_bytes: 256
n, m = (int(_) for _ in input().split())  
a = list(map(int, input().split()))
x = [list(int(_) for _ in input().split()) for i in range(m)]
x = sorted(x,key = lambda x:-x[1])

[a.extend(list(i[1] for ii in range(i[0]))) for i in x if len(a) <= n * 2]
a = sorted(a,key = lambda x:-x)

print(sum(a[:n]))

Measured memory_bytes: 50260
S = input() + 'O'
N = len(S)
n = [0] * (N - 1)
t = []
i = 0
j =  0
while S[i] != 'O':
    count = 0
    if S[i] == 'R':
        while S[i] == 'R':
            count += 1
            i += 1
    elif S[i] == 'L':
        while S[i] == 'L':
            count += 1
            i += 1
    t.append(count)
T = int(len(t)/2)  # len(t)は必ず偶数
for i in range(T):
    j += t[2*i]
    if t[2*i] % 2 == 0:
        if t[2*i + 1] % 2 == 0:
            n[j - 1] = int((t[2*i] + t[2*i + 1])/2)
            n[j] = n[j - 1]
        elif t[2*i + 1] % 2 == 1:
            n[j - 1] = int((t[2*i] + t[2*i + 1] - 1)/2)
            n[j] = n[j - 1] + 1
    elif t[2*i] % 2 == 1:
        if t[2*i + 1] % 2 == 0:
            n[j - 1] = int((t[2*i] + t[2*i + 1] + 1)/2)
            n[j] = n[j - 1] - 1
        elif t[2*i + 1] % 2 == 1:
            n[j - 1] = int((t[2*i] + t[2*i + 1])/2)
            n[j] = n[j - 1]
    j += t[2*i+1]
print(' '.join(map(str, n)))


Measured memory_bytes: 11252
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b) cout << c << endl;
	else if(b == c) cout << a << endl;
	else cout << b << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x[100009],y[100009];
long long use[1000];
char mp[4] = {'R','D','L','U'};
int main()
{
  long long N,M,i,j,k = 0,now = 1;
  vector<long long> temp;
  cin >> N;
  for(i = 0;i < N;i++)
  {
    cin >>x[i] >> y[i];
    if((x[i] + y[i]) % 2 == 0)
    {
      k++;
    }
  }
  if(k != N && k != 0)
  {
    cout << -1 <<endl;
    return 0;
  }
  cout << 40 <<endl;
  now = 1;
  if(k == N)
  {
    use[0] = 1;
    use[1] = 1;
    for(i = 0;i < N;i++)
    {
      x[i]--;
    }
  }
  else
  {
    use[0] = 1;
    use[1] = 2;
  }
  cout << use[0] << " " << use[1] << " ";
  for(i = 2;i < 40;i++)
  {
    use[i] = use[i-1]*2;
    cout << use[i] << " ";
  }
  cout <<endl;
  for(i = 0;i < N;i++)
  {
    temp.clear();
    for(j = 39;j > 0;j--)
    {
      if(abs(x[i]) > abs(y[i]))
      {
        if(x[i] > 0)
        {
          temp.push_back(2);
          x[i] -= use[j];
        }
        else
        {
          temp.push_back(0);
          x[i] += use[j];
        }
      }
      else
      {
        if(y[i] > 0)
        {
          temp.push_back(1);
          y[i] -= use[j];
        }
        else
        {
          temp.push_back(3);
          y[i] += use[j];
        }
      }
    }
    if(k == N)
    {
      temp.push_back(2);
    }
    else
    {
      if(abs(x[i]) > abs(y[i]))
      {
        if(x[i] > 0)
        {
          temp.push_back(2);
        }
        else
        {
          temp.push_back(0);
        }
      }
      else
      {
        if(y[i] > 0)
        {
          temp.push_back(1);
        }
        else
        {
          temp.push_back(3);
        }
      }
    }
    for(j = temp.size()-1;j >= 0;j--)
    {
      cout << mp[(temp[j]+2) % 4];
    }
    cout << endl;
  }
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void _main(){
  int N; cin >> N ;
  vl a(N);
  rep(i,N) cin >> a[i] ;
  int ami = int(min_element(ALL(a))-a.begin());
  int ama = int(max_element(ALL(a))-a.begin());
  ll mi = a[ami];
  ll ma = a[ama];
  vector<P> ans;
  if(mi<0 && ma>0){
    if(abs(mi)>=abs(ma)){
      rep(i,N){
        if(a[i]<=0) continue;
        ans.pb(P(ami,i));
        a[i] += a[ami];
      }
    }else{
      rep(i,N){
        if(a[i]>=0) continue;
        ans.pb(P(ama,i));
        a[i] += a[ama];
      }
    }
  }
  if(*max_element(ALL(a))<=0){
    RREP(i,N-1,1) ans.pb(P(i,i-1));
  }else{
    rep(i,N-1) ans.pb(P(i,i+1));
  }
  cout << ans.size() << endl;
  for(auto p:ans) cout << p.first+1 << " " << p.second+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,res,a,b;
    cin>>A>>B;
    res=(A+B)/2;
    a=A-res;
    b=B-res;
    if(abs(a)==abs(b))
    {
        cout<<res<<endl;
    }
    else
        cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll n, d, a, x, h;
    ll ans = 0;
    map<ll, ll> pos;
    cin >> n >> d >> a;
    for(int i = 0; i < n; i++) {
        cin >> x >> h;
        pos[x] += 1+(h-1)/a;
    }
    map<ll, ll> recover;
    ll effect = 0;
    while (!pos.empty()) {
        ll x_beg = pos.begin()->first;
        while (!recover.empty() && x_beg >= recover.begin()->first) {
            effect -= recover.begin()->second;
            recover.erase(recover.begin());
        }
        ll sub = pos.begin()->second-effect;
        if (sub <= 0) {
            pos.erase(pos.begin());
            continue;
        }
        ans += sub;
        // cout << "sub " << sub << ", at " << x_beg << endl;
        effect += sub;
        recover[x_beg+d*2+1] += sub;
        pos.erase(pos.begin());
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 12800
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,k,a[MAXN];
string str;
int main()
{
    cin>>str;
    int cnt=0;
    for(int i=0;i<(int)str.size();i++) if(str[i]=='x') cnt++;
    if(cnt>=8) puts("NO"); else puts("YES");
    return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
n_student = [list(map(int, input().split())) for i in range(N)]
m_point = [list(map(int, input().split())) for i in range(M)]

for x in range(N):
    min_y = 0
    min_value = 10**12
    for y in range(M):
        distance = abs(n_student[x][0] - m_point[y][0]) + \
            abs(n_student[x][1] - m_point[y][1])
        if distance < min_value:
            min_value = distance
            min_y = y + 1
    print(min_y)


Measured memory_bytes: 39408
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


AB = [list(map(int, sys.stdin.readline().split())) for _ in range(3)]

graph = [[] for _ in range(5)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)

ok = False
for a, b, c, d in itertools.permutations(range(1, 5)):
    ok |= b in graph[a] and c in graph[b] and d in graph[c]
if ok:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 13668