akhauriyash/Code-Regression huggingface dataset:
/***
	chauhan176's code

	DO WHATEVER IT TAKES!!!
	Nothing happens , nothing happens and then everything happens.
	But the thing is nothing happens in air:)-
***/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define maxn 300005
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define stringio cin.ignore(256, '\n')  //to take string input after taking integer inputs
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;

typedef pair<int,int>pi;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const ll mx = 1000000000000;
#define PI 3.14159265
vector<pi>af;
ll k;
ll n , a[maxn] , f[maxn];
bool check(ll t)
{
    ll cnt=0;
    for(int i=0;i<n;i++)
    {
        ll dif = a[i]*f[i]*1LL - t;
        if(dif<=0)continue;
        cnt+= dif/f[i];
        if(dif%f[i]!=0)
            cnt+=1;
    }
    if(cnt>k)
        return false;
    return true;
}
int main()
{
    fastio;
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>f[i];

    sort(a,a+n);sort(f,f+n);
    reverse(f,f+n);
    ll ti=-1;
    for(ll j=inf;j>=1;j/=2)
    {
        while(ti+j<=inf)
        {
            bool f = check(ti+j);
            if(!f)
                ti+=j;
            else break;
        }
    }
    cout<<ti+1<<endl;
    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define pi 3.14159265358979323846264338327950L
#define FOR(i,a,b) for(int i=a;i<b;i++)

int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    string s,t;
    cin>>s>>t;
    if(s.size()>=t.size())
        cout<<"No"<<endl;
    else
    {
        int flag=0;
        FOR(i,0,s.size())
        {
            if(s[i]!=t[i])
            {
                flag=1;
                break;
            }

        }
        if(flag==1)
        {
            cout<<"No"<<endl;
        }
        else
            cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(1000000)

def dfs(graph, node, dist):
    if graph[node-1][2] == 1:
        return
    else:
        graph[node-1][2] = 1
        graph[node-1][3] += dist
        if graph[node-1][3] % 2 == 0:
            graph[node-1][4] = 1
        else:
            pass
        ll = graph[node-1][0]
        for i in range(len(ll)):
            dfs(graph, ll[i], graph[node-1][3] + graph[node-1][1][i]);

def main():
    n = int(input())
    edge = []
    for i in range(n-1): edge.append(list(map(int,input().split())))

# graph[[node, node, ...], [dist, dist, ...], [reached or not], 
#       [dist from root], [color]]
    graph = [[[],[],0,0,0] for i in range(n)]
    for i in range(n-1):
        node1 = edge[i][0]
        node2 = edge[i][1]
        weight = edge[i][2]
        graph[node1-1][0].append(node2)
        graph[node2-1][0].append(node1)
        graph[node1-1][1].append(weight)
        graph[node2-1][1].append(weight)
    
    dfs(graph, 1, 0)
    for i in range(n):
        print(graph[i][4])

if __name__ == "__main__":
    main()


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	vector<int> a(n);
	FOR(i, 0, n) cin >> a[i];
	bool ok = true;
	
	int mx = 0;
	FOR(i, 0, n)
	{
		setmax(mx, a[i]);
		ok &= a[i] + 1 >= mx;
	}
	
	cout << (ok ? "Yes\n" : "No\n");
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
 
#define REP(i,s,N) for (int i=s;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;
 
 
ll ans=0;
 
int main(){
	int a,b,c;
    cin >> a >> b >> c;
    ans = a+b+c;
	if(ans > 21){
      cout << "bust" << endl;
    }else{
      cout << "win" << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <unordered_map>
//#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    int n;
    set<int> a;
    int tmp_a;
    bool different=true;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a.insert(tmp_a);
    }
    if(a.size()==n){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    } 
 
    return 0;
}

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

using namespace std;

const int N = 2e5 + 5;

const double PI = acos(-1.0);
const double SAVE = 20 - PI * 5;
const double BUANG = 20 - PI * 10;

struct segtree {
  segtree(int n) : n(n) {
    num.assign(n << 2, -N);
  }
  void update(int at, int val) {
    update(1, 0, n - 1, at, val);
  }
  void update(int p, int l, int r, int at, int val) {
    if (l == r) {
      num[p] = val;
      return;
    }
    int mid = (l + r) >> 1;
    if (at <= mid) {
      update(p + p, l, mid, at, val);
    } else {
      update(p + p + 1, mid + 1, r, at, val);
    }
    num[p] = max(num[p + p], num[p + p + 1]);
  }
  int find(int l, int r) {
    return find(1, 0, n - 1, l, r);
  }
  int find(int p, int l, int r, int ll, int rr) {
    if (ll <= l && r <= rr) return num[p];
    int mid = (l + r) >> 1;
    int ret = -N;
    if (ll <= mid) {
      ret = max(ret, find(p + p, l, mid, ll, rr));
    }
    if (mid < rr) {
      ret = max(ret, find(p + p + 1, mid + 1, r, ll, rr));
    }
    return ret;
  }
  int n;
  vector<int> num;
};

map<int, int> idx, idy;
set<int> alx, aly;
vector<int> allx, ally;

pair<int, int> a[N], from, to;
int n;
#define x first
#define y second

void reverse_x() {
  reverse(allx.begin(), allx.end());
  for (int i = 0; i < n; i++) {
    a[i].x = alx.size() - a[i].x - 1;
  }
  from.x = alx.size() - from.x - 1;
  to.x = alx.size() - to.x - 1;
}

void reverse_y() {
  reverse(ally.begin(), ally.end());
  for (int i = 0; i < n; i++) {
    a[i].y = aly.size() - a[i].y - 1;
  }
  from.y = aly.size() - from.y - 1;
  to.y = aly.size() - to.y - 1;
}

void encode(pair<int, int>& p) {
  p.x = idx[p.x];
  p.y = idy[p.y];
}

int main() {
  scanf("%d %d %d %d", &from.x, &from.y, &to.x, &to.y);
  alx.insert(from.x);
  aly.insert(from.y);
  alx.insert(to.x);
  aly.insert(to.y);
  
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].x, &a[i].y);
    alx.insert(a[i].x);
    aly.insert(a[i].y);
  }
  
  int id = 0;
  for (auto it : alx) {
    allx.push_back(it);
    idx[it] = id++;
  }
  id = 0;
  for (auto it : aly) {
    ally.push_back(it);
    idy[it] = id++;
  }
  
  encode(from);
  encode(to);
  for (int i = 0; i < n; i++) encode(a[i]);
  
  if (from.x > to.x) reverse_x();
  if (from.y > to.y) reverse_y();
  
  a[n] = from;
  a[n + 1] = to;
  sort(a, a + n + 2);
  
  int best = 0;
  segtree seg(aly.size());
  for (int i = 0; i < n + 2; i++) {
    if (a[i] == from) {
      seg.update(a[i].y, 0);
      //puts("FROM");
    }
    if (a[i] == to) {
      best = seg.find(0, a[i].y);
      //puts("TO");
    }
    //printf("actual: %d %d\n", a[i].x, a[i].y);
    //printf("%d %d\n", allx[a[i].x], ally[a[i].y]);
    if (a[i] != from && a[i] != to) {
      int cur = seg.find(0, a[i].y);
      seg.update(a[i].y, cur + 1);
    }
  }
  double ans = 0;
  int S = abs(allx[to.x] - allx[from.x]) + abs(ally[to.y] - ally[from.y]);
  if (best == min(abs(allx[to.x] - allx[from.x]), abs(ally[to.y] - ally[from.y])) + 1) {
    ans = 100LL * S - (best - 1) * SAVE - BUANG;
  } else {
    ans = 100LL * S - best * SAVE;
  }
  printf("%.15f\n", ans);
  return 0;
}


Measured memory_bytes: 44020
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
long long gcd(long long a, long long b) {
  // the greatest common divisor
  while (b != 0) {
    long long r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) {
  // the least common multiple
  return a * b / gcd(a, b);
}

int main() {
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  LL size = lcm(n, m);
  DUMP(size);
  VEC<LL> num;
  LL d = size / n;
  for (LL i = 0; i < size; i += d) {
    num.push_back(i);
  }
  d = size / m;
  for (LL i = 0; i < size; i += d) {
    num.push_back(i);
  }
  sort(ALL(num));
  // DUMP(num);
  bool ok = 1;
  REP(i, 0, num.size() - 1) {
    if (num[i] == num[i + 1]) {
      LL nn = size / n;
      LL mm = size / m;
      LL left = num[i] / nn;
      LL right = num[i] / mm;
      // DUMP(left, right, s[left],t[right]);
      if (s[left] != t[right]) {
        ok = 0;
        break;
      }
    }
  }
  if (ok)
    cout << size << endl;
  else
    cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 2744
import java.util.Scanner;

class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        
        int n = scanner.nextInt();
        String str = "";
        for (int i = 1; i <= n; i++){
            if( (i % 3 == 0) || (i % 10 == 3)){
                str += " " + Integer.toString(i);
            } else {
                int tmp = i;
                while (tmp > 0){
                    tmp /= 10;
                    if(tmp != 0 && (tmp % 10 == 3) ){
                        str += " " + Integer.toString(i);
                        break;
                    }
                }
            }
        }
        System.out.println(str);
    }
}


Measured memory_bytes: 185124
#include <bits/stdc++.h>
using namespace std;
int main(){
char aa;
  cin>>aa;
  switch (aa){
    case 'a':
      cout<<'b'<<endl;
      break;
    case 'b':
      cout<<'c'<<endl;
      break;
    case 'c':
      cout<<'d'<<endl;
      break;
    case 'd':
      cout<<'e'<<endl;
      break;
    case 'e':
      cout<<'f'<<endl;
      break;
    case 'f':
      cout<<'g'<<endl;
      break;
    case 'g':
      cout<<'h'<<endl;
      break;
    case 'h':
      cout<<'i'<<endl;
      break;
    case 'i':
      cout<<'j'<<endl;
      break;
    case 'j':
      cout<<'k'<<endl;
      break;
    case 'k':
      cout<<'l'<<endl;
      break;
    case 'l':
      cout<<'m'<<endl;
      break;
    case 'm':
      cout<<'n'<<endl;
      break;
    case 'n':
      cout<<'o'<<endl;
      break;
    case 'o':
      cout<<'p'<<endl;
      break;
    case 'p':
      cout<<'q'<<endl;
      break;
    case 'q':
      cout<<'r'<<endl;
      break;
    case 'r':
      cout<<'s'<<endl;
      break;
    case 's':
      cout<<'t'<<endl;
      break;
    case 't':
      cout<<'u'<<endl;
      break;
    case 'u':
      cout<<'v'<<endl;
      break;
    case 'v':
      cout<<'w'<<endl;
      break;
    case 'w':
      cout<<'x'<<endl;
      break;
    case 'x':
      cout<<'y'<<endl;
      break;
    case 'y':
      cout<<'z'<<endl;
      break;
    default:
      break;
  }
}
            

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
int A , B, C;
cin>>A>>B>>C;
if ( A != B && A!=C){
    cout<< A<< endl;
    }
    else if (B!=A && B!=C){
        cout<<B<< endl;
    }
    else {
        cout << C<< endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define ll long long
#define pb push_back
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define fr(i,a,b) for(ll i=(a);i<(b);i++)
#define frd(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl "\n"
#define inf ((long long) 1e18 + 10)
#define ve vector<ll>
using namespace std;
vector<bool> prime(100001,true);
void sieve(){
	ll n = 100000;
	for(ll i = 2; i*i <= n;i++ ){
		if(prime[i] == true){
			for(ll j = i * i ; j<=n ; j += i){
				prime[j] = false;
			}
		}
	}
	return ;
}

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	int n,k;
    cin>>k>>n;
    ve a(n);
    int val = 0;
    int s = 0;
    rep(i,n){
        cin>>val;
        s += val;
    }
    if(s > k){
        cout<<-1<<endl;
        return 0;
    }
    cout<<k - s<<endl;
    return 0;
}


Measured memory_bytes: 3664
x,n = map(int,input().split())
if(n==0):
    print(x)
    exit()

p = set(map(int,input().split()))

ans = -2
dif = 1000
for i in range(-1,102):
    if(i in p):
        continue
    dif_i = abs(i-x)
    if(dif > dif_i):
        dif = dif_i
        ans = i

print(ans)

Measured memory_bytes: 61952
from collections import Counter
n=int(input())
al=list(map(int,input().split()))
mod=10**9+7
cl=Counter(al)
if n%2==0:
    for i in range(1,n,2):
        if cl[i]!=2:
            print(0)
            break
    else:
        print(2**(n//2)%mod)
else:
    if cl[0]!=1:
        print(0)
        exit()
    for i in range(2,n,2):
        if cl[i]!=2:
            print(0)
            break
    else:
        print(2**(n//2)%mod)

Measured memory_bytes: 14820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define sz              3000005
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int main(){
    Fast;

    int n,a, i, cnt=0;
    cin>>n;
    for(i=1; i<=n; i++){
        cin>>a;
        if(i%2 && a%2)cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}



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

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

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

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

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

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

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

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    int a;cin>>a;
    cout << a + a*a + a*a*a << endl;
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


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

    int sum=0;
    rep(i,n){
        int a;
        cin>>a;
        sum+=a;
    }

    if(sum%2)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = []
mod = 10**9+7
d = [0 for i in range(n+1)]
d[0] = 1
d[1] = 1
if n >1 :
    d[2] = 2
for i in range(3,n+1):
    d[i] = d[i-1] + d[i-2]
if m != 0:
    d.append(0)
    for i in range(m):
        b = int(input())
        a.append(b)
    ans = 1
    if a[0] == 1:
        ans = 1
    else:
        ans = ans*d[a[0]-1]%mod
    for i in range(m-1):
        ans = ans*d[a[i+1]-a[i]-2]%mod
    ans = ans*d[n-a[m-1]-1]%mod
else:
    ans = d[n]%mod
print(ans)

Measured memory_bytes: 464144
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vi a(n); rep(i,n) cin >> a[i];
	vi x(n,0);
	rep(i,n){
		if(i%2==0) x[0] += a[i];
		else x[0] -= a[i];
	}
	rep2(i,1,n){
		x[i] = a[i-1]-x[i-1]/2;
		x[i] *= 2;
	}
	rep(i,n) cout << x[i] << endl;
}




Measured memory_bytes: 2048
#他の人の回答
n, m, x = map(int, input().split())
ca = [list(map(int,input().split())) for _ in range(n)]

add = []

for i in range(2**n):
    skill = [0]*(m+1)
    for j in range(n):
        if ((i>>j) & 1):
            skill = list(map(sum, zip(skill, ca[j])))
    if min(skill[1:])>=x:
        add.append(skill)

if add:
    add.sort()
    print(add[0][0])
else:
    print(-1)

Measured memory_bytes: 11136
#include<cstdio>
#define rg register
#define ci const int
#define cl const long long int

typedef long long int ll;

namespace IO {
	char buf[100];
}

template <typename T>
inline void qr(T &x) {
	char ch=getchar(),lst=' ';
	while(ch>'9'||ch<'0') lst=ch,ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	if(lst=='-') x=-x;
}

template <typename T>
inline void write(T x,const char aft,const bool pt) {
	if(x<0) {putchar('-');x=-x;}
	int top=0;
	do {
		IO::buf[++top]=x%10+'0';
		x/=10;
	}while(x);
	while(top) putchar(IO::buf[top--]);
	if(pt) putchar(aft);
}

template <typename T>
inline T mmax(const T _a,const T _b) {if(_b<_a) return _a;return _b;}
template <typename T>
inline T mmin(const T _a,const T _b) {if(_a>_b) return _b;return _a;}
template <typename T>
inline T mabs(const T _a) {if(_a<0) return -_a;return _a;}

template <typename T>
inline void mswap(T &_a,T &_b) {
	T _temp=_a;_a=_b;_b=_temp;
}

int n;

int main() {
	qr(n);
	rg int i=1;
	while(true) {
		if(i*i>n) break;
		++i;
	}
	--i;
	write(i*i,'\n',true);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,now_max=-1;
	long long ans=0;
	cin>>a;
	for (int i=0;i<a;i++)
	{
		cin>>b;
		now_max=max(now_max,b);
		ans+=now_max-b;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
bool isprime(long long n){
    if(n==1)return false;
    else{
    for(long long i=2;i*i<=n;i++){
        if(n%i==0) return false;
        else continue;
    }
    return true;
    }
}
int main() {
ll q;
cin >> q;
vector<ll> like_sum(100005);
like_sum[0] = 0;
for (ll i = 1; i < 100005; i++) {
    if (i % 2 == 0)
        like_sum[i] = like_sum[i - 1];
    else{
        ll k = (i + 1) / 2;
        if(isprime(i) && isprime(k)){
            like_sum[i] = like_sum[i - 1] + 1;
        }
        else
            like_sum[i] = like_sum[i - 1];
    }
}
for (ll i = 0; i < q;i++){
    ll l,r;
    cin >> l >> r;
    cout << like_sum[r] - like_sum[l-1] << endl;
    
}
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;

long long int DP[3000][3000];
long long int A[3000];

long long int INF = 100000000000000LL;

int main() {
	
	int N;
	cin >> N;
	
	for(int i = 0; i < 2100; i++){
		for(int j = 0; j < 2100; j++){
			DP[i][j] = -INF;
		}
	}
	
	for(int i = 0; i < N; i++){
		cin >> A[i];
		DP[i][i] = A[i];
	}
	
	for(int i = 1; i < N; i++){
		for(int j = 0; j < N; j++){
			if(i % 2 == 0){
				DP[j][(j + i) % N] = max(DP[(j + 1) % N][(j + i) % N] + A[j], 
										DP[j][(j + i - 1) % N] + A[(j + i) % N]);
			}else{
				if(A[j] >= A[(j + i + 1) % N]){
					DP[j][(j + i) % N] = max(DP[j][(j + i) % N], DP[(j + 1) % N][(j + i) % N]);
				}
				if(A[(j - 1 + N) % N] <= A[(j + i) % N]){
					DP[j][(j + i) % N] = max(DP[j][(j + i) % N], DP[j][(j + i - 1) % N]);
				}
			}
			//cout << DP[j][(j + i) % N] << " ";
		}
		//cout << endl;
	}
	
	long long int ans = 0;
	
	for(int i = 0; i < N; i++){
		ans = max(ans, DP[i][(i - 1 + N) % N]);
	}
	
	cout << ans << endl;
	
	return 0;
}




Measured memory_bytes: 45904
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef vector<int> VI;
using namespace std;
const int NMAX=200666;
const int INF=1000000666;
const LL INFLL=1000000000000666;
const LL maxv=100000;
const long double PI = acos(-1.0);
const int MAXT = 200000;

int t[2][4*NMAX];
int n;
int A[NMAX];
vector<int> G[NMAX];
pair<int, int> dt[NMAX];
int inv[NMAX];

void build(int n, int l, int r, bool q){
  //cout<<n<<"\n";
  if(l == r){
    if(1-(l%2) == q)
      t[q][n] = A[l];
    else
      t[q][n] = INF;
    return;
  }

  int piv = (l+r)>>1;

  build(2*n, l, piv, q);
  build(2*n + 1, piv+1, r, q);
  
  t[q][n] = min(t[q][2*n], t[q][2*n + 1]);

}

int query(int n, int l, int r, int ql, int qr, int q){
  if(ql <= l && r <= qr){
    return t[q][n];
  }
  int rs = INF;

  int piv = (l+r)>>1;

  if(ql<=piv){
    rs = min(rs, query(2*n, l, piv, ql, qr, q));
  }

  if(qr>piv){
    rs = min(rs, query(2*n+1, piv+1, r, ql, qr, q));
  }

  return rs;
}

int k = 0;
map<pair<int, int>, int> M;

void rec(int l, int r, bool q, int pr){
  int v = ++k;
  //cout<<k<<"\n";

  int lft = inv[query(1, 1, n, l, r, q)];
  int rht = inv[query(1, 1, n, lft+1, r, 1-q)];
  //cout<<lft<<" "<<rht<<"\n";
  
  dt[k] = {A[lft], A[rht]};
  M[dt[k]] = k;

  G[pr].pb(v);

  if(lft > l){
    rec(l, lft-1, q, v);
  }
  if(rht < r){
    rec(rht+1, r, q, v);
  }
  if(rht - lft >= 3){
    rec(lft+1, rht-1, 1-q, v);
  }

}

set<pair<int, int>> S;
void dfs(int v){
  for(int i=0; i<G[v].size(); ++i){
    int mini = 0;
    pair<int, int> minv = {INF, INF};
    for(auto el: G[v]){
      if(dt[el] < minv){
        minv = dt[el];
        mini = el;
      }
    }
    dfs(mini);
    dt[mini] = {INF, INF};
  }
}

void solve(){
  cin>>n;
  for(int i=1; i<=n; ++i){
    cin>>A[i];
    inv[A[i]] = i;
  }

  build(1, 1, n, 0);
  build(1, 1, n, 1);

  //cout<<query(1, 1, n, 1, 4, 0)<<"\n";
  //cout<<"ok \n";

  rec(1, n, 0, 0);
  //cout<<"ok \n";

  S.insert(dt[1]);
  while(!S.empty()){
    pair<int, int> cur = (*S.begin());
    S.erase(S.begin());
    cout<<cur.x<<" "<<cur.y<<" ";
    int ind = M[cur];
    for(auto el: G[ind]){
      S.insert(dt[el]);
    }
  }


  

}


int main()
{
    // Tic
    //clock_t t=clock();
    cout<<setprecision(10)<<fixed;
    ios_base::sync_with_stdio(0);

    //freopen("simetrii.in", "rt", stdin);
    //freopen("simetrii.out", "wt", stdout);

    solve();

    //Toc
    //t=clock()-t;
    //printf ("It took me %d clicks (%f seconds).\n",t,((float)t)/CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 34432
/* ITP1_10_A */
#include <stdio.h>
#include <math.h>

/* ??§?¨?????§??????? */
typedef struct coordinate_value
{
	double x;
	double y;
} point;

/* 2???????????¢????¨????????????¢??° */
double calc_distance(point p1, point p2);

int main(void)
{
	point pnt1, pnt2;
	
	pnt1.x = 0.0;
	pnt1.y = 0.0;
	pnt2.x = 0.0;
	pnt2.y = 0.0;
	
	scanf("%lf %lf %lf %lf", &pnt1.x, &pnt1.y, &pnt2.x, &pnt2.y);
	
	double distance = calc_distance(pnt1, pnt2);
	
	printf("%lf\n", distance);
	
	return 0;
}

/* 2???????????¢????¨????????????¢??° */
double calc_distance(point p1, point p2)
{
	double a = 0.0, b = 0.0;
	a = pow( (fabs(p2.x - p1.x)), 2);
	b = pow( (fabs(p2.y - p1.y)), 2);
	return sqrt( a + b );
}

Measured memory_bytes: 652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;++i)
int i,j,h,w,x,y,nx,ny,t,r,a[1010][1010],dx[]={0,1,0,-1},dy[]={1,0,-1,0};
char c;
queue<tuple<int,int,int>>q;
main(){
  cin>>h>>w;
  rep(i,h)rep(j,w){
    cin>>c;
    a[i][j]=100000;
    if(c=='#')q.emplace(i,j,0);
  }
  while(q.size()){
    tie(y,x,t)=q.front();q.pop();
    if(a[y][x]>t){
      a[y][x]=t;r=max(r,t);
      rep(i,4){
        ny=y+dy[i];nx=x+dx[i];
        if(!(nx<0||ny<0||nx>=w||ny>=h))q.emplace(ny,nx,t+1);
      }
    }
  }
  cout<<r;
}

Measured memory_bytes: 52552
from bisect import bisect
readline = open(0).readline
N = int(readline())
*A, = map(int, readline().split())
Q = int(readline())
ans = []
for q in range(Q):
    k = int(readline())
    ans.append("%d\n" % (A[bisect(A, k)-1] == k))
open(1, 'w').writelines(ans)


Measured memory_bytes: 24648
#include<bits/stdc++.h>
using namespace std;
int main(){
    int W,H,N;
    
    cin >> W >> H >> N;
    vector<vector<int>> wh(H,vector<int>(W,0));
    vector<int> x(N),y(N),a(N);
    int i,j,k;
    for(i=0;i<N;i++){
        cin >> x.at(i)>> y.at(i)>> a.at(i);
    }
    int co = 0;
    for(k=0;k<N;k++){
        if(a.at(k)==1){
            for(i=0;i<x.at(k);i++){
            for(j=0;j<H;j++){
            wh.at(j).at(i)=1;
            }
    }
        }
        else if(a.at(k)==2){
            for(i=x.at(k);i<W;i++){
            for(j=0;j<H;j++){
            wh.at(j).at(i)=1;
            }
    }
        }
        else if(a.at(k)==3){
            for(i=0;i<W;i++){
            for(j=0;j<y.at(k);j++){
            wh.at(j).at(i)=1;
            }
    }
        }
        else if(a.at(k)==4){
            for(i=0;i<W;i++){
            for(j=y.at(k);j<H;j++){
            wh.at(j).at(i)=1;
            }
    }
        }
    }
    for(i=0;i<W;i++){
        for(j=0;j<H;j++){
            if(wh.at(j).at(i)==0){
                co++;
            }
        }
    }
    cout << co << endl;
    return 0;
}

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

a = [[0, 0] for i in range(n)]

c = [[0, 0] for i in range(m)]

for i in range(n):
    a[i][0], a[i][1] = map(int, input().split())

for i in range(m):
    c[i][0], c[i][1] = map(int, input().split())

index = 0


for i in range(n):
    for j in range(m):
        if j == 0 :
            k = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]) +1

        di = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
        if di < k:
            index = j + 1
            k = di
    print(index)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N;cin>>N;if(N%2==0) cout<<N<<endl;else cout<<2*N<<endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  string query; getline(cin, query);
  vector<string> queryv;
  int pos = 1;
  while(pos < (int)(query.size())) {
    string now = "";
    while(query[pos] != '.' && pos < (int)(query.size())) {
      now.push_back(query[pos]);
      pos++;
    }
    queryv.push_back(now);
    pos++;
  }
  string line;
  vector<int> prev = {-1};
  vector<string> now;
  vector<vector<string>> v;
  while(getline(cin, line)) {
    int cnt = 0;
    int pos = 0;
    while(line[pos] == ' ') {
      cnt++;
      pos++;
    }
    if(cnt == prev.back()) {
      prev.pop_back();
      now.pop_back();
    } else if(cnt < prev.back()) {
      while(cnt != prev.back()) {
        prev.pop_back();
        now.pop_back();
      }
      prev.pop_back();
      now.pop_back();
    }
    if(line.back() == ':') {
      string key = line.substr(pos, (int)(line.size())-pos-1);
      prev.push_back(cnt);
      now.push_back(key);
    } else {
      int colonpos = 0;
      while(line[colonpos] != ':') colonpos++;
      string key = line.substr(pos, colonpos - pos);
      string val = line.substr(colonpos+2, (int)(line.size())-colonpos-2);
      prev.push_back(cnt);
      now.push_back(key);
      now.push_back(val);
      v.push_back(now);
      now.pop_back();
    }
  }
  bool ok = false;
  for(int i=0;i<(int)(v.size());++i) {
    if((int)(queryv.size()) > (int)(v[i].size())-1) continue;
    bool same = true;
    for(int j=0;j<(int)(queryv.size());++j) {
      same &= v[i][j] == queryv[j];
    }
    if(!same) continue;
    ok = true;
    if((int)(v[i].size()) - (int)(queryv.size())== 1) {
      cout << "string \"" << v[i].back() << "\"" << endl;
    } else {
      cout << "object" << endl;
    }
    break;
  }
  if(!ok) cout << "no such property" << endl;
}



Measured memory_bytes: 3316
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut t = vec![];
    for _ in 0..m {
        let s = sc.read::<usize>() - 1;
        let c = sc.chars()[0];
        t.push((s, c));
    }

    for i in 0..999 {
        let s: Vec<char> = i.to_string().chars().collect();
        if s.len() != n {
            continue;
        }
        let mut ok = true;
        for &(i, c) in t.iter() {
            if s[i] != c {
                ok = false;
                break;
            }
        }
        if ok {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4476
s = int(input())

def func(n):
  if n%2 == 0:
    return int(n/2)
  else:
    return int(3*n+1)
  
a = []
a.append(s)
i = 0
while(True):
  a.append(func(a[i]))
  i += 1
  try:
    if a[i] in a[:i]:
      print(i+1)
      break
  except:
    continue

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    
    sum += r-l+1;
  }
  
  cout << sum << endl;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

const int MAX_N = 10000,MAX_V = 10000,MAX_E = 1000000;
const int INF = 1e+6;

int par[MAX_N]; //父亲数组
int rankh[MAX_N]; //树的高度

void init(int n){
    for(int i = 0;i < n;i++){
        par[i] = i;  //初始化时让父亲等于自己,全部都是根
        rankh[i] = 0;
    }
}

int find(int x){  // 找x的根,并在找的过程中简化树(减小根节点某一子树的高度,对整棵树的高度有无影响是不知道的)
    if(x == par[x])  return x; // 找父亲等于自己的点就是根
    return par[x] = find(par[x]);  //不是根的话就继续从它的爸爸开始找,并且在找到根后把x的父亲改成根
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    //让高的根做矮的根
    if(rankh[x] < rankh[y]) par[x] = y;
    else{
        par[y] = x;
        if(rankh[x] == rankh[y]) rankh[x]++;
    }
}


bool same(int x, int y){
    return find(x) == find(y);
}

struct edge{
    int u,v;
    double cost;
};

int V, E;
edge es[MAX_E];

bool cmp(edge a, edge b){ return a.cost > b.cost;}

double kruskal(){
    //初始化
    init(V);
    sort(es, es+E, cmp);
//    printf("_______________________________\n");
//    for(int i = 0;i < E;i++){
//        printf("%d %d %f\n", es[i].u,es[i].v, es[i].cost);
//    }
//    printf("_______________________________\n");
    //按权值从小到大变量所有边(其实当连接边数==V-1就结束了,不过时间复杂度都在排序上,这里没太大影响)
    double res = 0;
//    int connum = 0;
    for(int i = 0;i < E;i++){
        edge e = es[i];
        if(!same(e.u, e.v)){
            unite(e.u, e.v);
            res+=e.cost;
//            printf("use:%d\n",i);
//            connum++;
        }
    }

//    if(connum == M) return 0;
    double sum = 0;
    for(int i = 0;i < E;i++){
        sum+=es[i].cost;
    }

    return sum - res;
}

double dist(double x1, double y1, double x2, double  y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

int x[MAX_V];
int y[MAX_V];

int main() {

    scanf("%d %d", &V, &E);
    for(int i = 0;i < V;i++){
       scanf("%d %d", &x[i], &y[i]);
    }
    for(int i = 0;i < E;i++){
        int u,v;
        scanf("%d %d", &u, &v);
        u--;v--;
        es[i].cost = dist(x[u], y[u], x[v], y[v]);
        es[i].u = u;
        es[i].v = v;
    }

    printf("%.3f", kruskal());
    return 0;
}


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

int main() {
  long long n;
  string s;
  cin >> n >> s;
  long long cnt=0;
  rep(i,n){
      if(s[i]==s[i+1]){
          continue;
      }
      cnt++;
  }
  cout << cnt << endl;
}



Measured memory_bytes: 512
import sys
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

def main():
    H, W = map(int, sys.stdin.readline().split())
    ca = np.array(sys.stdin.read().split(), dtype=np.int64)
    cost = ca[:100].reshape(10, 10)
    A = ca[100:]
    
    min_cost = floyd_warshall(csgraph=csr_matrix(cost), directed=True)

    total_cost = min_cost[np.absolute(A)].T[1].astype(np.int64).sum()
    print(total_cost)

if __name__ == "__main__":
    main()


Measured memory_bytes: 17744
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000

long long N, M, a[100009][3], maxn = -(1LL << 60);

int n,m,v,i,j;
void solve(){
  cin.tie(0);
  ll maxn=0;
  ios::sync_with_stdio(false);
  cin>>n>>m;
  repl(i,1,n+1) rep(j,3) cin>>a[i][j];
  rep(i,8){
    std::vector<ll> v;
    repl(j,1,n+1){
      ll S = 0;
      rep(k,3){
        if((i/(1<<k)) % 2 == 0) S+=a[j][k];
        else S-=a[j][k];
      }
      v.pb(S);
    }
    sort(all(v));
    reverse(all(v));
    ll ans = 0;
    rep(j,m) ans+=v[j];
    maxn = MAX(maxn,ans);
  }
  cout<<maxn<<endl;

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll num[30];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll s;
  cin >> s;
  const ll X = (ll) 1e9;
  if (s <= X) {
    cout << "0 0 1 0 0 " << s << '\n';
  } else {
    ll c = (s + X - 1) / X;
    cout << "0 0 " << X << " " << 1 << " " << X * c - s << " " << c << '\n';
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;
  cin >> N;
  long n = 0;
  
  for(long i=1; i<=N; i++) {
    if(i%3 != 0 && i%5 != 0) {
      n += i;
    }
  }
  
  cout << n << endl;
 
}

Measured memory_bytes: 3632
(defvar *price* (read))

(defun yes-no (b)
  (format t (if b "Yes" "No")))

(yes-no
  (loop for i from 0 to 25
        for seven = *price* then (- *price* (* i 4))
        thereis (and (>= seven 0)
                     (zerop (mod seven 7)))))


Measured memory_bytes: 13536
#include <stdio.h>

#define N 100001
 
int depth(int);
void output(int);
 
typedef struct{
   
  int parent;

  int left;

  int right;

}Node;  
 
Node tree[N];

int count;
 
int main(){
  
  int i, j, n, k, Nnode, child, l;
  
  scanf("%d", &n);
     
  for(i = 0 ; i < n ; i++){

    tree[i].parent = -1;

    tree[i].left = -1;

    tree[i].right = -1;

  }

  for(i = 0 ; i < n ; i++){

    scanf("%d %d", &Nnode, &k);

    for(j = 0 ; j < k ; j++){

      scanf("%d", &child);

      if(j == 0)
	tree[Nnode].left = child;
      else
	tree[l].right = child;
             
      l = child;

      tree[child].parent = Nnode;

    }

  }

  for(i = 0 ; i < n ; i++){
    count = 0;

    printf("node %d: parent = %d, depth = %d, ", i, tree[i].parent, depth(i));
         
    if(tree[i].parent == -1)
      printf("root, [");
    else if(tree[i].left == -1)
      printf("leaf, [");
    else
      printf("internal node, [");
	         
    count = 0;

    output(tree[i].left);

    printf("]\n");

    }

    return 0;

}
 
int depth(int a){

    if(tree[a].parent != -1){

        count++;

        return depth(tree[a].parent);

    }

    else
      return count;

}
 
void output(int b){
    
  if(b != -1){
    
    if(count != 0)
      printf(", ");
         
    count++;

    printf("%d", b);

    output(tree[b].right);

    }
  
}

Measured memory_bytes: 1784
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Vaibhav Pal
 */

#include <bits/stdc++.h>

using namespace std;

struct AChangingACharacter {

    void solve(istream& in, ostream& out) {
        int n,k;
        in>>n>>k;
        string s;
        in>>s;
        k--;
        s[k]=tolower(s[k]);
        out<<s<<"\n";
    }
};


int main() {
	AChangingACharacter solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import Data.List
main = getLine >> getLine >>= print.subtract 3.f.map length.group.sort.([0..10^5-1]++).map(read::String->Int).words
f [x,y,z] = x+y+z
f (x:y:z:rest) = max (x+y+z) $ f (y:z:rest)


Measured memory_bytes: 47484
n, a, b, c, d = list(map(int, input().split()))

flag = False
for k in range(1,n-1):
    if(k*c-(n-1-k)*d <= b-a and b-a <= k*d-(n-1-k)*c):
        flag = True
if(flag): print("YES")
else: print("NO")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll t;
cin>>t;
ll a[t];
for(ll i=0;i<t;i++)cin>>a[i];
ll ans=0;
for(ll i=0;i<t-1;i++)
{
    int  mx=a[i]-a[i+1];
     mx=max(0,mx);
     ans+=mx;
    if(a[i]>a[i+1])a[i+1]=a[i];
}
cout<<ans<<endl;
}

Measured memory_bytes: 5076
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, T := ReadInt(), ReadInt()
	t := ReadInts(N)
	ans := 0
	l, r := 0, 0
	for _, v := range t {
		if l <= v && v <= r {
			r = v + T
		} else {
			ans += r - l
			l, r = v, v+T
		}
	}
	ans += r - l
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 5924
def solve(N, T, ts):
    return sum([min(ts[i + 1] - ts[i], T) for i in range(N - 1)]) + T


if __name__ == "__main__":
    N, T = tuple(map(int, input().split(" ")))
    ts = list(map(int, input().split(" ")))
    print(solve(N, T, ts))


Measured memory_bytes: 25196
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string str;
	long int i, K;
	cin>>str;
	cin>>K;

	int cnt=0;
	for(i=0; i<str.size();++i) {
		if(str[i]=='1')++cnt;
		else break;
	}
	if(K<=cnt)cout<<1;
	else cout<<str[i];
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn read<T: FromStr + Default>() -> T {
    let mut x = String::with_capacity(5);
    io::stdin().read_line(&mut x).unwrap();
    if x.as_bytes()[x.len() - 1] == b'\n' {
        x.pop();
    }
    x.parse().unwrap_or_default()
}

fn main() {
    let mut count = [0, 0, 0, 0];
    for _ in 0..read() {
        let i = match &read::<String>()[..] {
            "AC" => 0,
            "WA" => 1,
            "TLE" => 2,
            _ => 3,
        };
        count[i] += 1;
    }
    println!("AC x {}", count[0]);
    println!("WA x {}", count[1]);
    println!("TLE x {}", count[2]);
    println!("RE x {}", count[3]);
}

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

using namespace std;

using int64 = long long;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
  int N, M, P[100000];
  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    cin >> P[i];
    --P[i];
  }
  UnionFind uf(N);
  for(int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    uf.unite(x, y);
  }
  vector< int > tap1[100000], tap2[100000];
  for(int i = 0; i < N; i++) {
    tap1[uf.find(i)].emplace_back(i);
    tap2[uf.find(i)].emplace_back(P[i]);
  }
  int ret = 0;
  for(int i = 0; i < N; i++) {
    for(auto &p : tap2[i]) {
      ret += binary_search(begin(tap1[i]), end(tap1[i]), p);
    }
  }
  cout << ret << endl;
}


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

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

using namespace std;

int main(){
	int n,t,a; cin>>n>>t>>a;
	int h[1000];
	rep(i,n) cin>>h[i];

	int ans=0;
	rep(i,n) if(abs(t-0.006*h[i]-a)<abs(t-0.006*h[ans]-a)) ans=i;
	cout<<ans+1<<endl;

	return 0;
}


Measured memory_bytes: 256