akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

int n,count = 0;
cin >> n;
vi v(n);
rep(i,n) cin >> v[i];

rep(i,n) if(v[i] % 2 == 0 && (v[i] % 3 != 0 && v[i] % 5 != 0)) count++;

if(count != 0) cout << "DENIED" << endl;
else cout << "APPROVED" << endl;


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a-b>c){
      System.out.println(0);
    }
    else{
		System.out.println(c-(a-b));
    }
  }
}

Measured memory_bytes: 23252
num_inputs = int(input())
input_array = input().split(' ')

for i in range(1, num_inputs):
    print(' '.join(input_array))
    current_value = input_array[i]
    j = i - 1
    while j >= 0 and int(input_array[j]) > int(current_value):
        input_array[j + 1] = input_array[j]
        j -= 1
    input_array[j + 1] = current_value
    
print(' '.join(input_array))


Measured memory_bytes: 5596
#include<iostream>
#include<vector>
#include <algorithm>

using namespace std;

const int N = 1000000;

bool data[N];
vector<int> vec;
int n;

void init(){
  fill(data, data+N, false);
  int sum = 3;
  for(int i=3;sum<N;i++){
    data[sum] = true;
    sum += i;
  }
}

bool check(){
  for(int i=0;i<vec.size();i++) if(vec[i] != i+1) return false;
  return true;
}

int solve(int sum){
  if(data[sum]){
    for(int cnt=0;;cnt++){
      if(cnt > 10000) return -1;
      if(check()) return cnt;
      int size = vec.size();
      for(int i=0;i<vec.size();i++) vec[i]--;
      vector<int> next;
      for(int i=0;i<vec.size();i++) if(vec[i]) next.push_back(vec[i]);
      vec = next;
      vec.push_back(size);
    }
  }
  return -1;
}

main(){
  init();
  int n;
  while(cin >> n && n){
    int sum = 0;
    vec.clear();
    for(int i=0;i<n;i++){
      int in;
      cin >> in;
      vec.push_back(in);
      sum += in;
    }
    cout << solve(sum) << endl;
  }
}

Measured memory_bytes: 2224
#ITP1_11-D Dice 4
store=[]
str=["N","S","E","W"]
rep={
    "N":[4,0,2,3,5,1],
    "S":[1,5,2,3,0,4],
    "E":[2,1,5,0,4,3],
    "W":[3,1,0,5,4,2]
}

def rotate_dice(b,s):
    result = [0,0,0,0,0,0]
    for i in range(6):
        result[i]=b[rep[s][i]]
    return result
    
def generate(b):
    if (b in store)==False:
        store.append(b)
        for s in str:
            generate(rotate_dice(b,s))

def check(a,b):
    generate(b)
    if a in store:
        return False
    else:
        return True

n=int(input())
dices=[0]*n
for i in range(n):
    dices[i]=input().split()
result = 1
i=0
while i < n-1:
    j=i+1
    while j < n:
        r = check(dices[i],dices[j])
        store = []
        result *= r
        j+=1
    i+=1

if result == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7768
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<tapu, Vtapu, greater<tapu> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
 

signed main(){
  LL A,B,X;
  cin >> X >> A >> B;
  string s;
  LL N;
  cin >> N;
  REP(i,N){
    cin >> s;
    if(s[0]=='n'){
      X=max(0LL,X+A);
    }else if(s[0]=='t'){
      X=max(0LL,X+B);
    }else{
      X=0;
    }
  }
  cout <<X << endl;
 	return 0;
}



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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

     multiset<ll> st;
    REP(i, n) {
        // a[i]未満の最大
        auto itr = st.lower_bound(a[i]);
        if(itr == st.begin()) {
            st.insert(a[i]);
        } else {
            itr--;
            st.erase(itr);
            st.insert(a[i]);
        }
    }

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

    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <sstream>
#include <cstdlib>
#include<list>
using namespace std;
int main(){
	list<int> lst;
	list<int>::iterator itr=lst.end();
	int n,i,q,x;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>q;
		if(q==0){
			cin>>x;
			itr=lst.insert(itr,x);
		}else if(q==1){
			cin>>x;
			if(x>0) for(int j=0;j<x;j++) itr++;
			else for(int j=0;j<abs(x);j++) itr--;
		}else{
			itr=lst.erase(itr);
		}
	}
	for(itr=lst.begin();itr!=lst.end();itr++){
		cout<<*itr<<endl;
	}
	return 0;
}


Measured memory_bytes: 18544
/*
  Ashraful Islam
  University of Asia Pacific
  Date:06th March 2020
  Category:Number Theory
  Todo--
  11957 - Checkers
  https://codeforces.com/problemset/problem/584/D
*/
#include<bits/stdc++.h>
#define all(o) (o).begin(),(o).end()
using namespace std;
typedef long long ll;
const int N=1e6+5;
long long n,m,len,k,cs=1,tc;
void scan(int &x)
{
  scanf("%d",&x);
}

void Solve()
{
 string s;
 cin>>s;
  

    int l=s.size();
    if(l&1)
    {
      cout<<"No"<<endl;
      return;
    }
  for(int i=0;i+1<s.size();)
  {
    if(s.substr(i,2)=="hi")
    i+=2;
    else
    {
      cout<<"No"<<endl;
      return;
    }
    
  }

  cout<<"Yes"<<endl;
}
int main()
{
  Solve();
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

d = {}
for i in range(0,n-1):
  if a[i] in d:
    d[a[i]] += 1
  else:
    d[a[i]] = 1
    
for i in range(1,n+1):
  if i in d.keys():
    print(d[i])
  else:
    print(0)

Measured memory_bytes: 33524
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  int n = readln.chomp.to!int;
  int k = readln.chomp.to!int;
  int sum = 0;
  foreach (x; readln.chomp.split.map!(to!int)) {
    sum += min(abs(x - k), x) * 2;
  }
  sum.writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    int a;
    REP(i, n) {
        cin >> a;
        q.emplace(a);
    }
    REP(i, m) {
        auto x = q.top(); q.pop();
        q.emplace(x / 2);
    }
    ll ans = 0;
    while (!q.empty()) {
        ans += (ll)q.top();
        q.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define all(x) (x).begin() (x).end()
#define rall(x) (x).rbegin() (x).rend()
typedef long long ll;

int main(){
	fastIO;
	ll x, dis;
	cin>>x>>dis;
	int cnt=0;
	while(x--){
		ll u, v;
		cin>>u>>v;
		ll d = u*u + v*v;
		if(d<=dis*dis)cnt++;
	}
	cout<<cnt<<endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    ll X;
    cin >> X;
    ll res = 1;
    for(int i=2;i<40;i++){
        ll tmp = i*i;
        if(tmp > X){
            continue;
        }
        while(tmp*i <= X){
            tmp *= i;
        }
        res = max(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000000
#define MAX2 10000

main(){
  unsigned short *A, *B;

  int BOX[MAX2+1];
  int n, i, j;
  scanf("%d", &n);

   A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<=MAX2;i++){
    BOX[i]=0;
  }

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

  for(i=1;i<=MAX2;i++){
    BOX[i]=BOX[i]+BOX[i-1];
  }
  
  for(j=1;j<=n;j++){
    B[BOX[A[j]]]=A[j];
    BOX[A[j]]--;
  }

  for (i=1;i<=n;i++){
    if (i>1)printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 9544
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		auto q = line.chomp.to!double;
		if (q == -1) break;
    immutable EPS = 0.00001 * q;
    auto x = q / 2;
    while (abs(x^^3-q) >= EPS) {
      x -= (x^^3-q) / (3*x^^2);
    }
		writefln("%.12f", x);
	}
}

Measured memory_bytes: 1124
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  int r,g,b;
  cin>>r>>g>>b;
  int n=100*r+10*g+b;
  if(n%4)cout<<"NO";
  else cout<<"YES";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define prsp(v) loop(i,0,v.size())cout<<v[i],sp;nl;
#define prpsp(v) loop(i,0,v.size())cout<<v[i].F<<" "<<v[i].S<<" , ";nl;
#define prnl(v) loop(i,0,v.size())cout<<v[i],nl;nl;
#define prpnl(v) loop(i,0,v.size())cout<<v[i].F<<" "<<v[i].S,nl;nl;
#define MOD 1000000007
#define mod(n) (((n%MOD)+MOD)%MOD)
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

vector<pii>gr[MAXN];
bool vis[MAXN];
int col[MAXN];

void dfs(int node, int par)
{
    vis[node]=1;
    for(int i=0;i<gr[node].size();i++)
    {
        int next = gr[node][i].F;
        if( !vis[next] )
        {
            col[next] = 3 - col[node];
            if( gr[node][i].S == 0 )
                col[next] = col[node];
            dfs(next,node);
        }
    }
}

int main() 
{
    fastio();

    int n,m,x,y,z;
    cin>>n>>m;
    loop(i,0,m)
    {
        cin>>x>>y>>z;
        x--,y--;
        gr[x].pb({y,z%2});
        gr[y].pb({x,z%2});
    }

    int cc=0;
    loop(i,0,n)
    {
        if( !vis[i] )
        {
            cc++;
            col[i]=2;
            dfs(i,-1);
        }
    }
    cout<<cc,nl;


    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 10880
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll n,sum=0,ans;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  if(n%2==0){
    sort(a,a+n);
    for(int i=0;i<n/2-1;i++){
      sum += a[n-1-i]*2;
    }
    sum += a[n-1-(n/2-1)];
    for(int i=0;i<n/2-1;i++){
      sum -=a[i]*2;
    }
    sum -=a[n/2-1];
    ans = sum;
  }else{
    sort(a,a+n);
    for(int i=0;i<n/2-1;i++){
      sum += a[n-1-i]*2;
    }
    sum += a[n-1-(n/2-1)];
    sum += a[n-2-(n/2-1)];
    for(int i=0;i<n/2;i++){
      sum -= 2*a[i];
    }
    ans = sum;
    sum=0;

    for(int i=0;i<n/2;i++){
      sum += a[n-1-i]*2;
    }
    for(int i=0;i<n/2-1;i++){
      sum -= 2*a[i];
    }
    sum -= a[n/2]+a[n/2-1];
    ans = max(ans,sum);
  }
  cout <<ans<<endl;
}


Measured memory_bytes: 1152
n = int(input())

import itertools
import collections

ref = ['7','5','3']

arr = []
for i in range(3,10):
    arr += list(itertools.product(ref, repeat=i))

ans = []
for i in range(len(arr)):
    c = arr[i]
    if '3' in c and '5' in c and '7' in c:
        t = ''.join(list(c))
        if int(t) <= n:
            ans.append(int(t))


ans.sort()
print(len(ans))
            


Measured memory_bytes: 9112
#define inr register int
#define ll long long
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
ll read(){
	char a=getchar();ll c=0,b=1;
	while(a<'0'||a>'9'){if(a=='-')b=-1;a=getchar();}
	while(a>='0'&&a<='9')c=c*10+a-48,a=getchar();
	return c*b;
}
int main(){
	ll n=read(),c=0;
	for(inr i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0)c+=i;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 3556
#include <cstdio>
#include <iostream>
#include <vector>
#include <iomanip>
#include <fstream>
#include <map>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <queue>

#define maxn 100010
#define inf 1e9

using namespace std;

typedef pair<int, int> point;

#define x first
#define y second

vector<string> list[210][210];

double sq(double a){
    return a*a;
}

int main() {
    // freopen("POLYGON.in", "r", stdin);
    // freopen("POLYGON.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    
    string s[110];
    vector<pair<int,int>> v;
    for (int i = 1; i <= n; ++i) {
        cin >> s[i];
        s[i] = "#" + s[i];
        for (int j = 1; j <= m; ++j) {
            if (s[i][j] == '#') {
                v.push_back({i, j});
            }
        }
    }
    
    sort(v.begin(), v.end());
    int x = 0;
    int y = 1;
    for (auto cell : v) {
        if (cell.x == x + 1 && cell.y == y || cell.x == x && cell.y == y+1) {
            x = cell.x;
            y = cell.y;
        } else {
            cout << "Impossible";
            return 0;
        }
    }
    
    if (x != n || y != m) {
        cout << "Impossible";
    } else {
        cout << "Possible";
    }
}

Measured memory_bytes: 1280
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
using static Func;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], M = I[1];
		var mat = MakeArray(M, _ => { var l = G; var s = 0ul; for (var i = 0; i < l[0]; i++) s |= One(l[i + 1] - 1); return s; });
		var p = G;
		var cnt = 0;
		for (var s = 0uL; s < One(N); s++)
		{
			var flag = true;
			for (var i = 0; i < M; i++) flag &= BitCount(s & mat[i]) % 2 == p[i];
			if (flag) cnt++;
		}
		WriteLine(cnt);
	}
	public static int BitCount(ulong n)
	{
		n = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555);
		n = (n & 0x3333333333333333) + ((n >> 2) & 0x3333333333333333);
		n = (n & 0x0f0f0f0f0f0f0f0f) + ((n >> 4) & 0x0f0f0f0f0f0f0f0f);
		n = (n & 0x00ff00ff00ff00ff) + ((n >> 8) & 0x00ff00ff00ff00ff);
		n = (n & 0x0000ffff0000ffff) + ((n >> 16) & 0x0000ffff0000ffff);
		return (int)((n & 0x00000000ffffffff) + ((n >> 32) & 0x00000000ffffffff));
	}
}
static class Func { }


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

int main(){
    int N, L;
    cin >> N >> L;
    string S[N];

    for(int i = 0; i < N; ++i) cin >> S[i];

    sort(S, S + N);

    for(int i = 0; i < N; ++i) cout << S[i];
    cout << endl;

}

Measured memory_bytes: 256
arr = input().split(" ")
H = int(arr[0])
K = int(arr[1])

HPs = input().split(" ")
HPs = [int(i) for i in HPs ]
HPs.sort(reverse=True)

if(K == 0):
    print(sum(HPs))
else:
    print(sum(HPs[K:]))


Measured memory_bytes: 25768
#include <iostream>
using namespace std;
int main() {
	int a, b, c, z;
	z = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c % i == 0) {
			z++;
		}
	}
	cout << z << endl;
	
	return 0;
}


Measured memory_bytes: 3092
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if((a + b) % 2 == 0){
            System.out.println((a + b) / 2);
        }else{
            System.out.println("IMPOSSIBLE");
        }
    }
}

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

using namespace std;

template<class INT>
std::vector<INT> get_min_prime_fact_table(INT n){
    std::vector<INT> lp(n + 1), P;
    for (INT i = 2; i <= n; i++){
        if (lp[i] == 0){
            lp[i] = i;
            P.push_back(i);
        }
        for (INT j = 0; j <= P.size() and P[j] <= lp[i] and i * P[j] <= n; j++)
            lp[i * P[j]] = P[j];
    }

    return lp;
}

template<class INT>
std::vector<INT> prime_factorize(INT n, std::vector<INT>& lp){
    vector<INT> res;
    while (n != 1){
        res.push_back(lp[n]);
        n /= lp[n];
    }

    return res;
}

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto &a: A) scanf("%d", &a);
    int g = 0;
    for (const auto &a: A)
        g = gcd(g, a);
    
    if (g != 1){
        puts("not coprime");
        return 0;
    }

    auto lp = get_min_prime_fact_table(int(1e6));
    vector<int> DP(1e6 + 1);
    DP[1] = 1;
    for (int i = 2; i <= int(1e6); i++)
        DP[i] = DP[i / lp[i]] * (lp[i] == lp[i / lp[i]] ? 1 : lp[i]);
    
    vector<int> P(1e6 + 1);
    for (const auto &a: A){
        for (const auto &p: prime_factorize(DP[a], lp)){
            if (P[p] == 1){
                puts("setwise coprime");
                return 0;
            }
            P[p]++;
        }
    }

    puts("pairwise coprime");
}


Measured memory_bytes: 19072
import sys

n, *a = map(int, sys.stdin.read().split())

def main():
  cnt = [0] * 9
  for x in a:
    cnt[min(x, 3200) // 400] += 1
  mi = 0
  for x in cnt[:8]: 
    if x: mi += 1
  ma = mi + cnt[8]
  mi = max(1, mi)
  print(mi, ma)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int[] n= ints();
        char[,] a = new char[n[0],n[1]];
        for (int i = 0; i < n[0]; i++)
        {
            string s = Console.ReadLine();
            for (int j = 0; j < n[1]; j++)
            {
                a[i, j] = s[j];
            }
        }
        var ans = new int[n[0],n[1]];
        for(int i = 0; i < n[0]; i++)
        {
         
            for(int j = 0; j < n[1]; j++)
            {
                if (a[i, j] == '#')
                {
                    if (i != 0 && j != 0)
                    {
                        ans[i - 1, j - 1]++;
                    }
                    if (i != 0 )
                    {
                        ans[i - 1, j]++;
                    }
                    if (i != 0 && j != n[1] - 1)
                    {
                        ans[i - 1, j + 1]++;
                    }
                    if (  j != 0)
                    {
                        ans[i , j - 1]++;
                    }
                    if ( j != n[1] - 1)
                    {
                        ans[i, j + 1]++;
                    }
                    if (i != n[0] - 1 && j != 0)
                    {
                        ans[i + 1, j - 1]++;
                    }
                    if (i != n[0] - 1 )
                    {
                        ans[i + 1, j]++;
                    }
                    if (i != n[0] - 1 && j != n[1] - 1)
                    {
                        ans[i + 1, j + 1]++;
                    }
                }
                
            }
        }
        for (int i = 0; i < n[0]; i++)
        {
            for (int j = 0; j < n[1]; j++)
            {
                if (a[i, j] == '#')
                {
                    Console.Write("#");
                }
                else { Console.Write(ans[i, j]); }
            }
            Console.WriteLine();
        }
        Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a / gcd(a, b) * b;
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
char a[5]={'a','e','i','o','u'};
int main(){
    char c;
    c=getchar();
    for(int i=0;i<5;i++){
        if(c==a[i]){
            cout<<"vowel"<<endl;
            return 0;
        }
    }
    cout<<"consonant"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		ArrayList<String> ans = new ArrayList<String>();
		
		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			BigInteger a = new BigInteger(br.readLine());
			BigInteger b = new BigInteger(br.readLine());
			if (a.toString().length() > 80 || b.toString().length() > 80 || a.add(b).toString().length() > 80) {
				ans.add("overflow");
				continue;
			}
			ans.add(a.add(b).toString());
		}
		
		for (String a : ans)
			System.out.println(a);
		
	}
	
}

Measured memory_bytes: 9688
#include <stdio.h>

int main(void){
	int i,n,p,max=100,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&p);
		sum += p;
		if(p>max) max = p;
	}
	sum -= max;
	sum += max*0.5;
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
string u="abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        puts("-1");
        return 0;
    }
    for(int i=0;i<26;i++){
        for(int j=0;j<s.length();j++){
            if(s[j]==u[i]) break;
            if(j==s.length()-1){
                s.pb(u[i]);
                cout << s << endl;
                return 0;
            }
        }
    }
    string t=s;
    for(int i=s.length()-1;i>=0;i--){
        if(s[i-1]>s[i]) t.erase(t.begin()+i); 
        else{
            t.erase(t.begin()+i);
            for(int k=0;k<26;k++){
                if(u[k]<t[i-1]) continue;
                for(int j=0;j<t.length();j++){
                    if(u[k]==t[j]) break;
                    if(j==t.length()-1){
                        t.erase(t.begin()+i-1);
                        t.pb(u[k]);
                        cout << t << endl;
                        return 0;
                    }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main() {
	ll n,in,ans=1;
	cin >> n;
	rep(i, n) {
		cin >> in;	
		ans = ans / gcd(ans, in) * in;
	}
	cout << ans << endl;
}


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int MOD = 998244353;

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

	int a, b, c; cin >> a >> b >> c;
	int k; cin >> k;

	int cnt = 0;
	while(b <= a){
		b *= 2;
		cnt++;
	}

	while(c <= b){
		c*=2;
		cnt++;
	}

	cout << (cnt <= k ? "Yes\n" : "No\n");

	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define INT long long
#define oo 6e18
using namespace std;
INT n, m, a[505][505];
vector<INT> ans;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i = 1 ; i <= n ; i++ ) for(int j = 1 ; j <= m ; j++ )
        cin>>a[i][j];
    for(int i = 1 ; i <= n ; i++ ) for(int j = 1 ; j <= m ; j++ )
        if( a[i][j] % 2 )
        {
            if( j+1 <= m )
            {
                a[i][j]--, a[i][j+1]++;
                ans.push_back(i), ans.push_back(j), ans.push_back(i), ans.push_back(j+1);
            }
            else
            {
                if( i+1 <= n )
                {
                    a[i][j]--, a[i+1][j]++;
                    ans.push_back(i), ans.push_back(j), ans.push_back(i+1), ans.push_back(j);
                }
            }
        }
    cout<<ans.size()/4<<endl;
    for(int i = 0 ; i < ans.size() ; i+=4 )
        cout<<ans[i]<<" "<<ans[i+1]<<" "<<ans[i+2]<<" "<<ans[i+3]<<endl;
    return 0;
}


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

namespace ABC125
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] V = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int[] C = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int res = 0;
            for (int i = 0; i < N; i++)
            {
                if (V[i] - C[i] > 0)
                {
                    res += V[i] - C[i];
                }
            }
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n, D1, D2, count;
  cin >> n;
  count = 0;
  
  for(int i = 0; i < n; i++){
    if(count == 3)break;
    cin >> D1 >> D2;
    if( D1 == D2) count++;
    else count = 0;
  }
  if(count >= 3)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3104
#include <iostream>
using namespace std;
int main(void){
 int t,n,o=0,s=0,f=0;
 while(1){
     o=0;
 cin>>t>>n;
 if(t==0)break;
 for(int i = 0;i<n;i++){
     cin>>s>>f;
   o=o+(f-s);
 }
  if(t<=o){
       cout<<"OK"<<endl;
   }   
    if(t>o){
       cout<<t-o<<endl;
   }  
 } 
}



Measured memory_bytes: 3112
def test():
    n = int(input())
    k = int(input())
    x = list(map(int,input().split()))
    a = 0; b = k
    count = 0
    for i in range(n):
        if abs(x[i]-a) <= abs(x[i]-b):
            count += 2*abs(x[i]-a)
        else:
            count += 2*abs(x[i]-b)
    print(count)


if __name__ == "__main__":
    test()


Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
	int c,a,b;
	
	while(1){
	scanf("%d",&a);
	b=1000-a;c=0;	
	while(b>=500){c++;b-=500;}
	while(b>=100){c++;b-=100;}
	while(b>=50){c++;b-=50;}
	while(b>=10){c++;b-=10;}
	while(b>=5){c++;b-=5;}	
	while(b>=1){c++;b-=1;}
	if(a==0)break;else printf("%d\n",c);
	}	
	return 0;
}

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

int main() {
	int n; cin >> n;
	map<int, int>A;
	for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		A[tmp] += 1;
	}

	long long ans = 0;
	for (auto&x:A) {
		if (x.second % 2 == 1)ans++;
	}
	cout << ans << endl;

	return 0;
}

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

{
     public:
    int minimumSteps(int a, int b)
     {
       int steps=0;
       while(a>b){
       a-=2;
       steps++;
       }
       while(b>a){
       a+=3;
       steps++;
       }
        while(a>b){
       a-=2;
       steps++;
       }
       while(b>a){
       a+=3;
       steps++;
       }
        while(a>b){
       a-=2;
       steps++;
       }
       while(b>a){
       a+=3;
       steps++;
       }
       return steps;
     }
};
const int N = 3e5+5;
int w[N];
int e[N];
int main()
{
 
    string s;
    int n;
    cin>>n;
    cin>>s;
    
    int mn=1e9;
    for(int i =0;i<s.length();i++)
    {
     w[i]+= (s[i]=='W');
     e[i]+= (s[i]=='E');
    }
    for(int i =1;i<s.length();i++)
    {
     w[i]+= w[i-1];
     e[i]+= e[i-1];
    // cout<<e[i]<<" "<<w[i]<<endl;
    }
    for(int i =0;i<s.length();i++)
    {
        int ws = w[i];
        if(s[i]=='W')
        ws--;
        int es = e[s.length()-1]- e[i];
        mn = min(mn,es+ws);
    }
    cout<<mn;
}
 



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

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if(x>0 && y>0 && x+r<=W && y+r<=H) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1156
fun main(args: Array<String>){
  val n: Int = readLine()!!.toInt()
  val l: List<Int> = readLine()!!.split(" ").map{it.toInt()}
  var x = 1
  var cnt = 0
  for(i in 0..n-1){
    when(l[i]){
      x -> x++
      else -> cnt++
    }
  }
  println(if(cnt==n) -1 else cnt)
}


Measured memory_bytes: 83272
// E - Strings of Impurity

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using mp_int = mp::cpp_int; // 任意長整数型

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

	map<char, vector<int>> pos_list;

	for (int i=0; i<s.size(); i++) {
		pos_list[s[i]].push_back(i);
	}

	for (int i=0; i<t.size(); i++) {
		if (pos_list[t[i]].size() == 0) {
			cout << -1 << endl;
			return 0;
		}
	}

	mp_int ans = 0;
	int ref = -1;
	for (int i=0; i<t.size(); i++) {
		char c = t[i];
		auto itr = upper_bound(pos_list[c].begin(), pos_list[c].end(), ref);
		if (itr == pos_list[c].end()) {
			ref -= s.size();
			i--;
			continue;
		}
		int pos = *itr;
		//cout << c << " ref=" << ref << " pos=" << pos << endl; // **** debug ****
		ans += pos - ref;
		ref = pos;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    int H,W,x,y,r;
    cin >> W >> H >> x >> y >> r;

    bool b;
    b = true;
    if(x+r > W){
        b = false;
    }else if(y+r > H){
        b = false;
    }else if(x-r < 0){
        b = false;
    }else if(y-r < 0){
        b = false;
    }
    if(b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;

int n;
char a[1010];

int check(int i,int j)
{int ret=1,p,k;
 
 for(p=1;p<=n-i;p++)
 {	ret=0;
 	for(k=0;k<=i;k++)
 		if(a[p+k]==96+j)
 		{	ret=1;
 			break;
 		}
 	if(!ret) return 0;
 }
 
 return 1;
}	

int main()
{int i,j,flag;
 
 scanf("%s",a+1);
 n=strlen(a+1);
 
 for(i=0;i<n;i++)
 {	flag=0;
 	for(j=1;j<=26;j++)
 		if(check(i,j))
 		{	//cout<<i<<" "<<j<<endl;
		 	flag=1;
 			break;
 		}
 	if(flag)
	{	printf("%d\n",i);
		return 0;
	}
 }
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  ll x;
  cin >> x;

  for(ll b = -120; b <= 120; ++b) {
    for(ll i = 0; i <= 240; ++i) {
      ll tmp = i - 120;
      if(pow(tmp, 5) - pow(b, 5) == x) {
        cout << tmp << " " << b << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 4092
def main():
    N = int(input())
    S = input()
    left_black = 0
    right_white = S.count('.')
    min_change = left_black + right_white
    for s in S:
        if s == '#':
            left_black += 1
        else:
            right_white -= 1
        min_change = min(min_change, left_black + right_white)
    print(min_change)


if __name__ == '__main__':
    main()


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

char s[100][100];

int main(){
	int len1,len2,len3;
	for(int i = 1;i <= 3;i++){
		scanf("%s",s[i] + 1);
	}
	len1 = strlen(s[1] + 1);
	len2 = strlen(s[2] + 1);
	len3 = strlen(s[3] + 1);
	if(s[1][len1] == s[2][1] && s[2][len2] == s[3][1]){
		printf("YES");
	}
	else printf("NO");
}

Measured memory_bytes: 256
sum=0
n=int(input())
l=list(map(int,input().split()))
for i in range(n):
  if i%2==1:
    sum-=l[i]
  else:
    sum+=l[i]
res=[sum]
print(sum,end=' ')
for i in range(n-1):
  res.append(2*(l[i]-res[i]//2))
  print(res[-1],end=' ')

Measured memory_bytes: 14028
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val _ = in.readLine().toInt
    val Array(t, a) = in.readLine().split("\\s+").map(_.toInt)
    val hs = in.readLine().split("\\s+").map(_.toInt)

    val tm = t * 1000
    val am = a * 1000
    out.println(hs.map(h => Math.abs(tm - h * 6 - am)).zipWithIndex.minBy(_._1)._2 + 1)

    out.flush()
  }
}


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

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value


void solve() {
	
	int N = in();

	vector<pair<double,int>> a;
	double sum = 0;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		a.pb(make_pair(tmp, i));
		sum += tmp;
	}

	sum /= N;

	for (int i = 0; i < N; i++) {
		a[i].fst = fabs(a[i].fst - sum);
	}

	int ans = 0;
	double min = INF;
	for (int i = 0; i < N; i++) {
		if (min > a[i].fst) {
			ans = i;
			min = a[i].fst;
		}
	}

	cout << ans << endl;

	return;

}

int main() {

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

	solve();

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,x;
	scanf("%lld %lld",&n,&x);
	ll ans=n;
	ll a=x,b=n-x;
	while(1){
		if(a>b)swap(a,b);
		if(b%a==0){ans+=b*2-a;break;}
		ans+=2*(b-(b%a));
		b%=a;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 5005
#define M 5005
#define LL long long

struct zz {
	int ed,last,c;
} z[M<<1];
int G[N],cot = 0;
void Add(int s,int e,int c) {
	z[++cot].ed = e,z[cot].last = G[s],z[cot].c = c,G[s] = cot;
	return ;
}

vector <int> E[N];
int Q[N],mark[N],deg[N],dis[N],dp[N],mem[N];
struct xx {
	int u,v,c;
} w[M<<1];

void dfs(int x) {
	mem[x] = 1;
	for(int i=0; i<(int)E[x].size(); i++) {
		int e = E[x][i];
		if(!mem[e]) dfs(e);
	}
	return ;
}
int main() {
	int n,m,p;
	cin >> n >> m >> p;
	for(int i=1,a,b,c; i<=m; i++) {
		scanf("%d%d%d",&a,&b,&c);
		Add(b,a,c-p);
		E[a].push_back(b);
	}
	dfs(1);
	int L = 1,R = 0,tot = 0;
	Q[++R] = n,mark[n] = 1;
	while(L <= R) {
		int x = Q[L++];
		for(int i=G[x]; i; i=z[i].last) {
			int e = z[i].ed;
			if(!mark[e]) {
				mark[e] = 1,Q[++R] = e;
			}
			if(mem[e]) w[++tot] = (xx) <% e,x,z[i].c %>;
			deg[e] ++;
		}
	}

	memset(dp,-66,sizeof(dp));
	dp[1] = 0;
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=tot; j++) {
			int s = w[j].u,e = w[j].v;
			if(dp[s] + w[j].c > dp[e]) dp[e] = dp[s] + w[j].c;
		}
	}
	for(int j=1; j<=tot; j++) {
		int s = w[j].u,e = w[j].v;
		if(dp[s] + w[j].c > dp[e]) {
			puts("-1");
			return 0;
		}
	}
//	for(int i=1;i<=n;i++) cout<<dp[i]<<" ";
//	cout<<endl;
//	for(int i=1; i<=tot; i++) cout<<w[i].u<<" "<<w[i].v<<" "<<w[i].c<<endl;
	cout<<max(0,dp[n])<<endl;
//	memset(dis,-66,sizeof(dis));
//	L = 1,R = 0;
//	Q[++R] = n,dis[n] = 0;
//	while(L <= R) {
//		int x = Q[L++];
//		for(int i=G[x]; i; i=z[i].last) {
//			int e = z[i].ed;
//			if(!mark[e]) continue;
//			-- deg[e];
//			dis[e] = max(dis[e],dis[x] + z[i].c);
//			if(!deg[e]) Q[++R] = e;
//		}
//	}
//	cout<<max(0,dis[1]);
	return 0;
}


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




int main() {
  string S;
  int Q;
  cin >> S >> Q;

  deque<char> ans;  
  for (int i = 0; i < S.size(); i++) {
    ans.push_back(S[i]);
  }
  bool notReverse = true;
  for (int i = 0; i < Q; i++) {
    int T;
    cin >> T;
    if(T==1) {
      notReverse = !notReverse;
      continue;
    }
    int F;
    char C;
    cin >> F >> C;
    
    bool setHead = (F==1);
    
    if (notReverse == setHead){
      ans.push_front(C);
    } else {
      ans.push_back(C);
    }
  }
  
  if (notReverse){
    for(auto itr = ans.begin(); itr != ans.end(); ++itr) {
        cout << *itr;
    }
  } else {
    for(auto itr = ans.rbegin(); itr != ans.rend(); ++itr) {
        cout << *itr;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 896