akhauriyash/Code-Regression huggingface dataset:
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

// https://qiita.com/drken/items/a14e9af0ca2d857dad23#4-%E7%B4%A0%E5%9B%A0%E6%95%B0%E5%88%86%E8%A7%A3
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;  // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    // answer flug
    bool pairwise_coprime = true;
    bool setwise_coprime = true;

    set<int> prime_factors_set;

    // pairwise coprime
    for (int i = 0; i < n; i++) {
        auto prime_factors = prime_factorize(a[i]);

        for (auto &&i : prime_factors) {
            if (prime_factors_set.count(i.first)) {
                pairwise_coprime = false;
            }
            prime_factors_set.insert(i.first);
            if (!pairwise_coprime) break;
        }

        if (!pairwise_coprime) break;
    }

    // setwise coprime
    int cumgcd = a[0];
    for (int i = 0; i < n; i++) {
        cumgcd = gcd(a[i], cumgcd);
    }
    setwise_coprime = cumgcd == 1;

    // answer
    if (pairwise_coprime)
        cout << "pairwise coprime" << endl;
    else if (setwise_coprime)
        cout << "setwise coprime" << endl;
    else
        cout << "not coprime" << endl;
}


Measured memory_bytes: 7284
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y, lli p){
    lli res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
vector<vll> S;
vll dp;
lli solve(){
	lli n;
	lli M = 1e9 + 7;
	cin>>n;
	S.clear();
	S.resize(n, vll(n));
	loop(i, 0, n)	
		loop(j, 0, n)	cin>>S[i][j];
	dp.clear();
	lli N = pow(2, n);
	dp.resize(N, 0);
	dp[0] = 1;
	loop(i, 1, N){
		lli p = 0;
		vll pos;
		loop(j, 0, n){
			if(1<<j & i){
				p++;
				pos.pb(j);
			}
		}
		if(p == 1){
			if(S[0][pos[0]] == 1)
				dp[i] = 1;
			else
				dp[i] = 0;
		}
		else{
			loop(j, 0, p){
				dp[i] = (dp[i] + (S[p-1][pos[j]] == 1 ? dp[i - (1<<pos[j])] : 0))%M;
			}
		}
//		cout<<i<<" "<<p<<" "<<dp[i]<<"\n";
	}
	cout<<dp[N-1]<<"\n";
	return 0;
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}


Measured memory_bytes: 16640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> prime;
  map<int, ll> amap;
  int tmp;
  for(int i=1;i<=N;++i) {
    tmp = i;
    for(int j=2;j*j<=tmp;++j) {
      if(tmp%j==0) {
        if(amap[j]==0) prime.push_back(j);
        while(tmp%j==0) {
          amap[j]++;
          tmp /= j;
        }
      }
    }
    if(tmp>1) {
      if(amap[tmp]==0) prime.push_back(tmp);
      amap[tmp]++;
    }
  }
  ll ans = 1;
  for(int i=0;i<prime.size();++i) {
    ans *= amap[prime[i]]+1;
    ans %= mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3584
b, a = map(int, input().split())

white = '.' * 100
black = '#' * 100
wb = '.#' * 50

ban = []

num_b = b - 1
num_a = a - 1

gyo_b = num_b // 50
ret_b = num_b % 50

gyo_a = num_a // 50
ret_a = num_a % 50

for i in range(gyo_a):
    ban.append(wb)
    ban.append(white)

ban.append(('.#' * ret_a + ('..' * (50 - ret_a))))
ban.append(white)

for i in range(50 - 2 * (gyo_a + 1)):
    ban.append(white)

for i in range(50 - 2 * (gyo_b + 1)):
    ban.append(black)

for i in range(gyo_b):
    ban.append(wb)
    ban.append(black)

ban.append('.#' * ret_b + '##' * (50 - ret_b))
ban.append(black)

print(100, 100)

for item in ban:
    print(''.join(item))


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

int main(){
    ll n, d;
    cin>>n>>d;
    ll ans=0;
    ll x[n][d];
    for(ll i=0;i<n;++i){
        for(ll j=0;j<d;++j){
            cin>>x[i][j];
        }
    }

    for(ll i=0;i<n-1;++i){
        for(ll j=i+1;j<n;++j){
            ll flag=0;
            for(ll k=0;k<d;++k){
                flag += pow(x[i][k]-x[j][k], 2);
            }

            for(ll k=0;k<1e3;++k){
                if(flag==k*k){
                    ans++;
                    break;
                }else if(flag<k*k){
                    break;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// JOI14-quest2.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <stdio.h>


int main(void)
{
	int friends, number, target[100], value[100][100] = { 0 }, score[100] = { 0 };

	scanf("%d", &friends);
	scanf("%d", &number);

	for (int i = 0; i < number; i++) {
		scanf("%d ", &target[i]);
	}

	for (int i = 0; i < number; i++) {
		for (int j = 0; j < friends; j++) {
			scanf("%d", &value[i][j]);
		}
	}

	int miss_count = 0;

	for (int i = 0; i < number; i++) {
		miss_count = 0;
		for (int j = 0; j < friends; j++) {
			if (value[i][j] == target[i]) {
				score[j]++;
			}
			else {
				miss_count++;
			}
		}
		score[target[i] - 1] += miss_count;
	}

	for (int i = 0; i < friends; i++) {
		printf("%d\n", score[i]);
	}

	return 0;
}

Measured memory_bytes: 1072
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    vector<pair<int, int>> w;
    REP(i, n)
    {
        int a, b;
        cin >> a >> b;
        w.push_back(make_pair(b, a));
    }
    sort(w.begin(), w.end());

    /* 
    REP(i, n)
    {
        cout << w[i].first << " " << w[i].second << endl;
    }
    */

    int cur = 0;
    int remain = 0;
    REP(i, n)
    {
        remain += w[i].first - cur;
        remain -= w[i].second;
        cur = w[i].first;

        if (remain < 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

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; }
typedef pair <ll,ll> P;


int main()
{
    ll A, B;
    cin >> A >> B;
    if (A % 3 == 0 | B % 3 == 0 | (A+B) % 3 == 0) {
        cout << "Possible" << endl;
    } else cout << "Impossible" << endl;
    return 0;
}


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


void solve(long long A, long long B){
	long int range = 20*fmax(A,B);
	bool OK = false;
	for(long int i=1;i<range;i++){
		if((((int)(i*0.08))==A)&&(((int)(i*0.1))==B)){
			cout << i << endl;
			OK = true;
			break;
		}
	}
	if(OK==false){
		cout << "-1" << endl;
	}


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int main()
{
    int N;
    long D;
    cin >> N >> D;
    long X[N];
    long Y[N];
    for (int i = 0; i < N; i++)
    {
        cin >> X[i];
        cin >> Y[i];
    }

    int res = 0;
    for (int i = 0; i < N; i++)
    {
        long distance = X[i] * X[i] + Y[i] * Y[i];
        long DD = D*D;
        if (DD >= distance)
            res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 6744
#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <memory.h>
using namespace std;
const int INF = 2 << 27;
#define ll long long
typedef pair<int,int> P;

static int dp[4][500001];


int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    int r,t;
    cin >> r >> t;
    int rr = r / 100;
    int tt = t / 30;
    int dr = (r % 100==0)?1:2;
    int tr = (t % 30==0)?1:2;
    for(int i = 0; i < tr; i++) {
      for(int j = 0; j < dr; j++) {
        if(i != 0 || j != 0) cout << " ";
        cout << ((rr+j) + 5 * (tt+i));
      }
    }
    cout << endl;
  }
}

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

signed main() {
	int n;
	cin >> n;
	vector<double> x(n), y(n);
	for (auto& e : x) {
		cin >> e;
	}
	for (auto& e : y) {
		cin >> e;
	}

	double d = 0;

	for (int i = 0; i < n; ++i) {
		d += abs(x[i] - y[i]);
	}

	printf("%.6lf\n", d);
	d = 0;

	for (int i = 0; i < n; ++i) {
		d += (x[i] - y[i]) * (x[i] - y[i]);
	}

	printf("%.6lf\n", sqrt(d));
	d = 0;

	for (int i = 0; i < n; ++i) {
		d += abs((x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]));
	}

	printf("%.6lf\n", cbrt(d));
	d = 0;


	for (int i = 0; i < n; ++i) {
		d = max((int)d, abs((int)(x[i] - y[i])));
	}

	printf("%.6lf\n", d);
}
		






Measured memory_bytes: 3404
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DFriction {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int h, w; cin >> h >> w;
      int ans = 0;
      vector<vector<char>> mat(w, vector<char>(h));
      rep(i, h) {
        rep(j, w) {
          cin >> mat[j][i];
        }
      }

      rep(i, w-1) {
        vector<vector<int>> cost(h+1, vector<int>(h+1));
        for(int k=-h+1; k<h; k++) {
          int cnt = 0;
          for(int a=0; a<h; a++) {
            auto b = a+k;
            if (b < 0 || h <= b) continue;
            if (mat[i][a] == mat[i+1][b]) cnt++;
            cost[h-1-a][h-1-b] = cnt;
          }
        }

        rep(j, h) {
          rep(k, h) {
            debug(j, k, cost[j][k]);
          }
        }

        vector<vector<int>> dp(h+1, vector<int>(h+1, INT_MAX/2));
        dp[0][0] = 0;
        rep(j, h+1) {
          rep(k, h+1) {
            if (j+1 <= h) {
              chmin(dp[j+1][k], dp[j][k] + cost[j][k]);
            }
            if (k+1 <= h) {
              chmin(dp[j][k+1], dp[j][k] + cost[j][k]);
            }
          }
        }
        debug(dp[h][h]);
        ans += dp[h][h];
      }
      cout << ans << endl;

    }
};

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

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>

typedef long long int llint;

int main(void){

  int n, m;
  std::cin >> n >> m;

  std::vector<llint> H(n);
  for(int i=0; i<n; i++){
    std::cin >> H[i];
  }

  std::vector<llint> A(m), B(m);
  for(int j=0; j<m; j++){
    std::cin >> A[j] >> B[j];
    A[j]--;
    B[j]--;
  }

  std::vector<bool> good(n, true);
  for(int j=0; j<m; j++){
    if(H[A[j]] <= H[B[j]]) good[A[j]] = false;
    if(H[A[j]] >= H[B[j]]) good[B[j]] = false;
  }

  int count = 0;
  for(const auto& elem: good){
    if(elem) count++;
  }


  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 5636
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;


int main()
{
	long w, h, x, y;
	double answer;
	cin >> w >> h >> x >> y;

	answer = double(w * h) / 2;

	if ((double(w) / 2 == double(x)) && (double(h) / 2 == double(y))) {
		cout << setprecision(10) << answer << " " << 1 << endl;
	}
	else {
		cout << setprecision(10) << answer << " " << 0 << endl;
	}
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BC114
{
    class Program
    {
        static void Main(string[] args)
        {
            var obj = new Q1();
            obj.Solver();

        }
    }
    class Q1
    {
        static void Search(int n, string s, ref List<int> list)
        {
            if (n + 1 == s.Length) return;
            else if (s.Distinct().Count() == 3) list.Add(int.Parse(s));
            Search(n, "3" + s, ref list);
            Search(n, "5" + s, ref list);
            Search(n, "7" + s, ref list);
        }

        public void Solver()
        {
            int n = int.Parse(Console.ReadLine());
            var list = new List<int>();
            Search(9, "", ref list);
            list = list.OrderBy(f => f).ToList();
            int ans = 0;
            for (int i = 0; i < list.Count(); i++)
            {
                if (list[i] <= n) ans++;
                else break;
            }
            Console.WriteLine(ans);
        }
    }
    //class Q1
    //{

    //    public void Solver()
    //    {
    //        long amswer = 753;
    //        var s = Console.ReadLine().Select(x => long.Parse(x.ToString())).ToArray();
    //        long diff = 1000;

    //        for (int i = 0; i < s.Count() - 2; i++)
    //        {
    //            long temp = s[i] * 100 + s[i + 1] * 10 + s[i + 2];
    //            diff = Math.Min(diff, Math.Abs(amswer - temp));
    //        }

    //        Console.WriteLine(diff);

    //    }
    //}

    //class Q1
    //{
    //    public void Solver()
    //    {
    //        var age = int.Parse(Console.ReadLine());

    //        Console.WriteLine((age == 3 || age == 5 || age == 7) ? "YES" : "NO");

    //    }
    //}
}


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

int main(){

    int n;
    cin >> n;

    vector<int> c(n),v(n);

    rep(i,n){
        cin >> v[i];
    }

    rep(i,n){
        cin >> c[i];
    }

    rep(i,n){
        v[i]-=c[i];
    }

    ll ans=0;
    rep(i,n){
        if(v[i]>0){
            ans+=v[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define nmod         -1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define xxx         exit(0);
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x)/log(base));
}
ll h,w,n,dp[200005],f[200005],fc[200005];
ll ways(ll x,ll y)
{
	if(x<0 || y<0) return 0;
	return (((f[x+y]*fc[x])%mod)*fc[y])%mod; 
 }
bool cc(pii &a, pii &b)
{
	return (a.F+a.S) < (b.F+b.S);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS; 
    while(TESTS--)
    {
    	ll i,l,j,x1,y1,x,y,q,h;
    	cin>>h>>w>>n;
    	vector<pii> z(n+1);
    	rep(i,0,n)
		{
    		cin>>x1>>y1;
    		z[i]={x1,y1};
		}
		z[n]={mod,mod};
		sort(all(z),cc);
		z[n]={h,w};
		f[0]=1; fc[0]=1; dp[0]=0;
		repi(i,1,200004)
		{
			f[i]=(f[i-1]*i)%mod;
			fc[i]=mod_Expo(f[i],mod-2,mod);
			dp[i]=0;
		}
		repi(i,0,n)
		{
			dp[i]=ways(z[i].F-1,z[i].S-1);
			rep(j,0,i)
			{
				if(z[i].F>=z[j].F && z[i].S>=z[j].S)
				dp[i] = (dp[i]-((ways(z[i].F-z[j].F,z[i].S-z[j].S)*dp[j])%mod) + mod)%mod;
			}
		}
		cout<<dp[n];
	}
	return 0;
}

Measured memory_bytes: 8356
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,M;
int A[10000];

int main(){
    cin>>N>>M;
    rep(i,M) cin>>A[i];

    int ans=N;
    rep(i,M){
        ans-=A[i];
    }
    ans=max(ans,-1);

    cout<<ans<<endl;
}

Measured memory_bytes: 3644
N = int(input())
S_L = list(map(int, input().split()))
Q = int(input())
T_L = list(map(int, input().split()))


def bisect(a_l, x):
    _l = 0
    _r = len(a_l)-1
    while _r - _l > 1:
        _c = (_l + _r)//2
        _tmp = a_l[_c]
        if _tmp == x:
            return _c
        elif _tmp > x:
            _r = _c
        else:
            _l = _c
    if a_l[_l] == x:
        return _l
    elif a_l[_r] == x:
        return _r
    else:
        return False


ans = 0
for i in range(Q):
    if bisect(S_L, T_L[i]) is not False:
        ans += 1

print(ans)



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

#define NINFINITE -100000000000000

vector<long long int> weight,val;
vector<long long int> dp[101];
long long int n,w;

long long int rec(int idx,int W)
{
    if(idx==n)
    {
        if(W<0)
            return NINFINITE;
        else
            return 0;
    }
    if(W<0)
        return NINFINITE;
    if(dp[idx][W]!=0)
        return dp[idx][W];
    long long int a,b;
    a=val[idx]+rec(idx+1,W-weight[idx]);
    b=rec(idx+1,W);
    return dp[idx][W]=max(a,b);
}

int main()
{
    cin>>n>>w;
    long long int i,j;
    for(i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        weight.push_back(x);
        val.push_back(y);
        for(j=0;j<=w;j++)
            dp[i].push_back(0);
    }
    long long int mval=rec(0,w);
    cout<<mval;
    return 0;
}


Measured memory_bytes: 79348
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
a = rl()
cnt = 0
for i in range(n-1):
    if a[i] == a[i+1]:
        a[i+1] = -1
        cnt += 1
print(cnt)



Measured memory_bytes: 13776
#include<cstdio>
#include<iostream>
#define For(i , j , k) for (int i = (j) ; i <= (k) ; ++ i)
#define Fordown(i , j , k) for (int i = (j) ; i >= (k) ; -- i);
using namespace std;

const int maxn = 110;
int a[maxn][maxn] , n , m , N;
int sum[maxn * maxn];

int main()
{
	scanf("%d%d%d" , &n , &m , &N);
	For(i , 1 , N)
	{
		scanf("%d" , &sum[i]);
	}
	int now = 1;
	For(i , 1 , n)
	{
		if (i % 2)
		{
			For(j , 1 , m)
			{
				a[i][j] = now;
				-- sum[now];
				if (!sum[now])
					++ now;
			}
		}
		else
		{
			for (int j = m ; j >= 1 ; -- j)
			{
				a[i][j] = now;
				-- sum[now];
				if (!sum[now])
					++ now;
			}
		}
	}
	For(i , 1 , n)
	{
		For(j , 1 , m - 1)
			printf("%d " , a[i][j]);
		printf("%d\n" , a[i][m]);
	}
	return 0;
}


Measured memory_bytes: 384
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)
//#define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

//using namespace __gnu_pbds;

using namespace std;

//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n, m, ans;
int a, b, c;
int A[11111], B[1111], C[1111];

vector <pii> E[11111];

int v[1111][1111];
int v1[11111];

bool vis[111111];

void tap(int nd)
{
	FOR (i, 1, n)
		v[nd][i] = inf;
	
	v[nd][nd] = 0;
	
	priority_queue <pii, vector<pii>, greater<pii> > Q;
	
	Q.push({0, nd});
	
	memset(vis, 0, sizeof(vis));
	
	while (!Q.empty()) {
		int val = Q.top().ff;
		int node = Q.top().ss;
		
		Q.pop();
		
		if (vis[node])
			continue;
		
		for (auto i: E[node])
			if (v[nd][i.ff] > val+i.ss)
				v[nd][i.ff] = val+i.ss, Q.push({v[nd][i.ff], i.ff});
	}
}

void good(int nd, int qq)
{
	FOR (i, 1, n)
		v1[i] = inf;
	
	v1[nd] = qq;
	
	priority_queue <pii, vector<pii>, greater<pii> > Q;
	
	Q.push({qq, nd});
	
	memset(vis, 0, sizeof(vis));
	
	while (!Q.empty()) {
		int val = Q.top().ff;
		int node = Q.top().ss;
		
		Q.pop();
		
		if (vis[node])
			continue;
		
		for (auto i: E[node])
			if (v1[i.ff] > val+i.ss)
				v1[i.ff] = val+i.ss, Q.push({v1[i.ff], i.ff});
	}
}

int main()
{
	scanf("%d%d", &n, &m);
	
	FOR (i, 1, m) {
		scanf("%d%d%d", &a, &b, &c);
		E[a].pb({b, c});
		E[b].pb({a, c});
		
		A[i] = a;
		B[i] = b;
		C[i] = c;
	}
	
	FOR (i, 1, m)
		tap(i);
	
	FOR (i, 1, m) {
		good(B[i], C[i]);
		
		bool ok = 0;
		FOR (h, 1, n)
			if (v[A[i]][h] == v1[h])
				ok = 1;
		
		good(A[i], C[i]);
		FOR (h, 1, n)
			if (v[B[i]][h] == v1[h])
				ok = 1;
		
		if (!ok)
			ans++;
	}
	
	printf("%d", ans);
}


Measured memory_bytes: 4992
s = gets.chomp

if s == "SUN"
  puts "7"
elsif s == "MON"
  puts "6"
elsif s == "TUE"
  puts "5"
elsif s == "WED"
  puts "4"
elsif s == "THU"
  puts "3"
elsif s == "FRI"
  puts "2"
else 
  puts "1"
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
string s;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>s;
	for(int i=0;i+2<sz(s);i++){
		if(s[i]==s[i+1]||s[i]==s[i+2]||s[i+1]==s[i+2]){
			cout<<i+1<<' '<<i+3;
			re 0;
		}
	}
	if(sz(s)==2&&s[0]==s[1]) cout<<"1 2";
	else cout<<"-1 -1";
	re 0;
}

Measured memory_bytes: 3756
# 入力
N = int(input())
A = list(map(int, input().split()))

C = [abs(a) for a in A]
# 負である要素の数が偶数ならば、すべて非負にできる
# そうでなければ、絶対値が最小の要素を除いたすべての要素を非負にする
ans = (
    sum(C) if sum(a < 0 for a in A) % 2 == 0 else
    sum(C) - 2 * min(C)
)

# 出力
print(ans)


Measured memory_bytes: 14412
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(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 repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    bool can = false;
    repp(i,1,10) {
        repp(j,1,10) can |= N == i * j;
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];
    let mut s = read_as_string().chars().collect::<Vec<char>>();

    let mut ans = std::usize::MAX;

    let num_e = s.iter().filter(|x| **x=='E').count();
    let num_w = n - num_e;
    let mut right: (usize, usize) = (num_e, num_w);
    let mut left: (usize, usize) = (0, 0);

    for &p in &s{
        if p == 'E'{
            right.0 -= 1;
        }else{
            right.1 -= 1;
        }

        ans = cmp::min(ans, left.1 + right.0);

        if p == 'E'{
            left.0 += 1;
        }else{
            left.1 += 1;
        }
    }

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


Measured memory_bytes: 6396
import java.util.Scanner;
	public class Main{
      public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
        int n = sc.nextInt();
   
        for(int i =0; i<n; i++){
         int a = sc.nextInt();
          h -= a;
        }
		if(h<=0){
          System.out.println("Yes");
        }else {
          System.out.println("No");
        
        }
	}
}

Measured memory_bytes: 45268
#include<iostream>
#include<vector>
using namespace std;
#define BLANK 0
#define LOSE 1
#define BACK 2
int main()
{
  int N,T,L,B;
  int i,j,k;
  while(cin>>N>>T>>L>>B,N|T|L|B){
    vector<int>board(N+1,BLANK);
    vector< vector<double> >dp(T+1,vector<double>(N+1,0));
    vector< vector<double> >rest(T+1,vector<double>(N+1,0));
    for(i=0;i<L;i++){
      int t;
      cin>>t;
      board[t]=LOSE;
    }
    for(i=0;i<B;i++){
      int t;
      cin>>t;
      board[t]=BACK;
    }

    dp[0][0]=1;
    for(i=1;i<=T;i++){
      dp[i][N]+=dp[i-1][N];
      for(j=0;j<=N-1;j++){
	dp[i][j]+=rest[i-1][j];
	for(k=1;k<=6;k++){
	  int t;
	  if(j+k>N)t=N-((j+k)%N);
	  else t=j+k;
	  if(board[t]==BACK){
	    dp[i][0]+=dp[i-1][j]/6.0;
	  }else if(board[t]==LOSE){
	    rest[i][t]+=dp[i-1][j]/6.0;
	  }else{
	    dp[i][t]+=dp[i-1][j]/6.0;
	  }
	}
      }
    }
    printf("%8.6f\n",dp[T][N]);
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main() {
  
  int n,m;
  
  cin>>n>>m;
  
  int a[m];
  
  int sum=0;
  
  for(int i=0;i<m;i++) {
      cin>>a[i];
      sum+=a[i];
  }
  
  if(sum>n) {
      cout<<-1;
  }
  
  else {
      cout<<n-sum;
  }
  
  
    
    return 0;
}

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

using namespace std;

int m = 1000000007;

int addMod(int a, int b) {
    return (a % m + b % m) % m;
}

int subMod(int a, int b) {
    int x = (a % m - b % m) % m;
    if (x < 0) {
        x += m;
    }
    return x;
}

int multMod(int a, int b) {
    return (int)(((long long)(a % m) * (b % m)) % m);
}

int main() {
    int n;
    cin >> n;
    int a[n];

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int sums[n + 1] = {0};
    for (int i = 0; i < n; i++) {
        sums[i + 1] = addMod(sums[i], a[i]);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = addMod(ans, multMod(a[i], subMod(sums[n], sums[i + 1])));
    }
    
    cout << ans << "\n";
}

Measured memory_bytes: 5132
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [isize; n],
        q: usize,
        bc: [(isize, isize); q],
    }
    let mut ans = a.iter().sum::<isize>();
    let mut cnt: HashMap<isize, isize> = HashMap::new();
    for ai in a {
        *cnt.entry(ai).or_default() += 1;
    }

    for (bi, ci) in bc {
        let x = match cnt.remove(&bi) {
            Some(x) => x,
            None => 0,
        };
        *cnt.entry(ci).or_default() += x;
        ans += (ci - bi) * x;
        println!("{}", ans);
    }
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll N;
  cin>>N;
  for(ll i=-1000;i<1000;i++){
    for(ll j=-1000;j<1000;j++){
      if(i*i*i*i*i-j*j*j*j*j==N){cout<<i<<" "<<j<<endl;return 0;}
    }
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int>v(3);
  cin >> v.at(0) >> v.at(1) >> v.at(2);
  
  sort(v.begin(),v.end());
  int k = v.at(2) - v.at(0);
  int l = v.at(2) - v.at(1);
  
  if ((k+l) % 2 == 0) {
    cout << (k+l) / 2 << endl;
  }
  else {
    cout << (k+l+1) / 2 +1 << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
for i in a:
    #print(i)
    if i % 2 == 0:
        #print(i)
        if i % 3 != 0 and i % 5 != 0:
            print("DENIED")
            exit()
print("APPROVED")

Measured memory_bytes: 2940
count = int(input())
list = []
for i in range(count):
  list.append(input())
a = list.count("AC")
b = list.count("WA")
c = list.count("TLE")
d = list.count("RE")
print("AC x " + str(a))
print("WA x " + str(b))
print("TLE x " + str(c))
print("RE x " + str(d))

Measured memory_bytes: 16184
from collections import deque
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
s = [input() for _ in range(H)]
queue = deque()
dist = [[-1] * W for _ in range(H)]
queue.append((0, 0))
dist[0][0] = 0
move = [(1, 0), (0, 1), (-1, 0), (0, -1)]
while queue:
    i, j = queue.popleft()
    for di, dj in move:
        ni, nj = i + di, j + dj
        if 0 <= ni < H and 0 <= nj < W and s[ni][nj] == '.' and dist[ni][nj] == -1:
            dist[ni][nj] = dist[i][j] + 1
            queue.append((ni, nj))
ans = 0
if dist[-1][-1] == -1:
    ans = -1
else:
    ans = sum(row.count('.') for row in s) - (dist[-1][-1] + 1)
print(ans)

Measured memory_bytes: 40304
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double 
#define MOD 1000000007ll 
#define pb push_back
#define vl vector<ll>
#define pll pair<ll,ll>
#define mp make_pair
using namespace std;
#define pi (long double)3.14159265358979323846 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);
}
ll power(ll a,ll p,ll m)
{
    ll re=1;
    re%=m;
    for(;p;p>>=1){
        if(p&1) re=re*a%m;
        a=a*a%m;
    }
    return re;
}
ll inverseMOD(ll a,ll m)
{
    return power(a,m-2,m);
}
int main()
{

    ll n;
    cin>>n;
    ll sum[n],dif[n];
    for(ll i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        sum[i] = x+y;
        dif[i] = x-y;
    }
    sort(sum,sum+n);
    sort(dif,dif+n);
    cout<<max(dif[n-1]-dif[0],sum[n-1]-sum[0])<<endl;
    
}

Measured memory_bytes: 6720
void main()
{
    long a, b, h, m;
    rdVals(a, b, h, m);

    double ay = a * sin(2.0 * PI * (h.to!double / 12 + m.to!double / (12 * 60)));
    double ax = a * cos(2.0 * PI * (h.to!double / 12 + m.to!double / (12 * 60)));
    double by = b * sin(2.0 * PI * m.to!double / 60);
    double bx = b * cos(2.0 * PI * m.to!double / 60);

    double result = hypot(ay-by, ax-bx);

    writefln("%.15f", result);
}

enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

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

int main()
{
	int x,y,s,temp;
	while(cin >> x >> y >> s,x || y || s){
		temp = 0;
		for(int i = 1;i <= s;i++){
			for(int j = 1;j < i;j++){
				if(j*(100+x)/100+(i-j)*(100+x)/100 == s){
					if(j*(100+y)/100+(i-j)*(100+y)/100 > temp)
					temp = j*(100+y)/100+(i-j)*(100+y)/100;
				}
			}
		}
		cout << temp << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace	std;
int main(){

  int n,graph[100][100]={},a,b,tmp;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    for(int j=0;j<b;j++){
      cin>>tmp;
      graph[a-1][tmp-1]=1;
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j) cout<<" ";
      cout<<graph[i][j];
    }
    cout<<endl;
  }

  return 0;

}

Measured memory_bytes: 3132
type
	intArray = array[1..100000] of longint;
var i,j,m,n,k : integer;
    t,u       : longint;
    h         : intArray;

procedure	swap(var a,b:longint);
var tmp:longint;
begin
	tmp:=a;
	a:=b;
	b:=tmp
end;
    
procedure QuickSort(var a:intArray;start_index,end_index:integer);
var i,j,x,t:longint;
begin
	x:=a[(start_index+end_index)div 2];
	i:=start_index;
	j:=end_index;
	while(true)do
	begin
		while(a[i]<x)do i:=i+1;
		while(x<a[j])do j:=j-1;
		if(i<j)then
		begin
			swap(a[i],a[j]);
			i:=i+1;
			j:=j-1;
		end else
		begin
			if(start_index<i-1)then QuickSort(a,start_index,i-1);
			if(j+1<end_index)then QuickSort(a,j+1,end_index);
			exit;
		end;
	end;
end;
    
begin
  readln(n,k);
  for i := 0 to n - 1 do readln(h[i]);
  QuickSort(h, 0, n - 1);
  t := 999999999;
  for i := 0 to n - k do begin
    u := h[i + k - 1] - h[i];
    if t > u then t := u
  end;
  writeln(t)
end.

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

using namespace std;

int main() {
    vector<int> n(5);
    for (int i = 0; i < 5; i++) {
        cin >> n[i];
    }
    int k;
    cin >> k;

    if (n[4] - n[0] <= k)
        puts("Yay!");
    else
        puts(":(");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())


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

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

int main(){
    ll a,b,c;
    cin >> a >> b >> c;

    cout << a*b/2 << endl;

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin>>s;
  bool flag=true;
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      if(s.at(i)=='R'||s.at(i)=='U'||s.at(i)=='D'){
        flag=true;
      }
      else{
        flag=false;
        break;
      }
    }
    else{
      if(s.at(i)=='L'||s.at(i)=='U'||s.at(i)=='D'){
        flag=true;
      }
      else{
        flag=false;
        break;
      }
    }
  }
  if(flag==true){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.util.regex.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		s.next();
		int k=s.nextInt();
		Matcher m=Pattern.compile("(.)\\1*").matcher(s.next());
		List<Integer>l=new ArrayList<>();
		while(m.find())
			l.add(m.group().length());
		System.out.println(l.stream().mapToInt(i->i-1).sum()+Math.min(k*2,l.size()-1));
	}
}


Measured memory_bytes: 51392
n=gets.to_i
as=gets.split.map{|m| m.to_i}
ans=[0]*n
j=0
as.each_with_index do |an,i|
  if i.even?
    j+=an
  else
    j-=an
  end
end
ans[0]=j
1.upto(n-1) do |i|
  ans[i]=as[i-1]*2-ans[i-1]
end
puts ans.join(" ")


Measured memory_bytes: 14084
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
        public static void main(String[] args) throws Exception {
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st;
                PrintWriter pw = new PrintWriter(System.out);

                st = new StringTokenizer(br.readLine());
                long n = Long.parseLong(st.nextToken());
                long a = Long.parseLong(st.nextToken());
                long b = Long.parseLong(st.nextToken());
                long diff = Math.abs(b-a);
                if(diff%2==0) {
                        pw.println(diff/2);
                }
                else {
                        long x = Math.min(a, b);
                        long y = Math.max(a, b);
                        long dis = x-1+1;
                        long temp = y;
                        temp -= dis;
                        long win = dis + temp/2;
                        dis = n-y+1;
                        temp = n-x;
                        temp -= dis;
                        long lose = dis + temp/2;
                        pw.println(Math.min(win,lose));
                }



                pw.flush();
                pw.close();
        }
}


Measured memory_bytes: 22484
#include <iostream>
using namespace std;
typedef long long ll;
ll help_taro(int** grid,int n){
	ll** dp = new ll*[n];
	for(int i=0;i<n;i++){
		dp[i] = new ll[3];
	}
	for(int j=0;j<3;j++){
		dp[n-1][j] = grid[n-1][j];
	}
	for(int i=n-2;i>=0;i--){
		for(int j=2;j>=0;j--){
			int o1,o2;
			if(j==0){
				o1 = dp[i+1][j+1];
				o2 = dp[i+1][j+2];
			}else if(j==1){
				o1 = dp[i+1][j-1];
				o2 = dp[i+1][j+1];
			}else{
				o1 = dp[i+1][j-1];
				o2 = dp[i+1][j-2];
			}
			dp[i][j] = max(o1,o2) + grid[i][j];
		}
	}
	ll ans = -999;
	for(int j=0;j<3;j++){
		ans = max(ans,dp[0][j]);
	}
	return ans;
}
int main(){
	int n;
	cin >> n;
	int** grid = new int*[n];
	for(int i=0;i<n;i++){
		grid[i]= new int[3];
		for(int j=0;j<3;j++){
			cin >> grid[i][j];
		}
	}
	cout << help_taro(grid,n) << endl;
}

Measured memory_bytes: 8064
#include <cstdio>
#include <algorithm>

using namespace std;

const int INF = 1e9;
const int MAX = 100;

int main(){
  int n,r[MAX],c[MAX];
  int dp[MAX][MAX];

  scanf("%d" ,&n);
  for(int i = 0 ; i < n ; i++){
    scanf("%d %d" ,&r[i] , &c[i]);
  }

  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      dp[i][j] = INF;
    }
  }

  for(int i = 0 ; i < n ; i++){
    dp[i][i] = 0;
  }
 
  for(int i = 1 ; i < n ; i++){
    for(int j = 0 ; j < n-i ; j++){
      for(int k = j ; k < i + j ; k++){
	int M = r[j] * c[k] * r[k+1] * c[i+j];
	dp[j][i+j] = min(dp[j][i+j],dp[j][k] + dp[k+1][i+j] + M);
      }
    }
  }

  printf("%d\n" ,dp[0][n-1]);

  return 0;
}

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

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

  int cnt = 0;
  int ans = 0;
  for(char c : s){
    if(c=='A' || c=='C' || c=='G' || c=='T') cnt++;
    else{
      ans = max(ans, cnt);
      cnt = 0;
    }
  }

  ans = max(ans, cnt);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int t[200011];

void solveSingleCase(int caseNo)
{
    int N, T;
    cin >> N >> T;
    READRANGE(t, t + N);

    lint total = 0, begin = 0, end = T;
    FOR(i, 1, N) {
        if (t[i] > end) {
            total += end - begin;
            begin = t[i];
            end = begin + T;
        } else {
            end = t[i] + T;
        }
    }
    total += end - begin;
    cout << total << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 1024
//
//  main.cpp
//  ITP1_4-D
//
//  Created by ?????¶??? on 15/8/14.
//  Copyright (c) 2015??´ ?????¶???. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int count;
    cin >> count;
    
    long number;
    
    std::vector<long> numbers;
    
    for(int i = 0; i < count; i++){
        
        cin >> number;
        
//        cout << i << endl;
        
        numbers.push_back(number);
    }
    
    
//    printf("numbers count : %d" , static_cast<int>(numbers.size()));
    
    
    long max = numbers.front();
    long min = numbers.front();
    long sum = 0;
    
    
    for (int i = 0; i < numbers.size(); i++) {
        
        max = std::max(numbers[i], max);
        min = std::min(numbers[i], min);
        
        sum += numbers[i];
        
    }
    
    printf("%ld %ld %ld\n", min, max, sum);
    
    return 0;
}

Measured memory_bytes: 1324
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

const int D[][2] = {{1,0},{-1,0},{0,1},{0,-1}}; 
vector<vector<int>> M, S;
vector<vector<bool>> vis, fvis, Qvis;
int h,w, dh,dw; 
bool found_goal = false;
int answer = -1;

void DFS(int y,int x, int mv){
	if(y == dh && x == dw){
		found_goal = true;
		answer = mv;
	}
	vis[y][x] = true;
	S[y][x] = mv;
	for(int i=0;i<4;i++){
		int ny = y + D[i][0], nx = x + D[i][1];
		if(y + D[i][0] <= 0 || y + D[i][0] > h || x + D[i][1] <= 0 || x + D[i][1] > w ) continue;
		if(!M[ny][nx]) continue;
		if(vis[ny][nx]) continue;
		DFS(ny,nx,mv);
	}
}

void find_jump(int y, int x, queue<vector<int>>& Q, int mv){
	fvis[y][x] = true;
	
	// find magic jump
	for(int i=-2;i<=2;i++){
		for(int j=-2;j<=2;j++){
			if(!i && !j) continue;
			int ny = y + i, nx = x + j;
			if(ny <= 0 || ny > h || nx <= 0 || nx > w ) continue;
			if(!M[ny][nx]) continue;
			if(vis[ny][nx]) continue;
			if(Qvis[ny][nx]) continue;
			Q.push(vector<int>({ny,nx,mv}));
			Qvis[ny][nx] = true;
		}
	}
	
	for(int i=0;i<4;i++){
		int ny = y + D[i][0], nx = x + D[i][1];
		if(y + D[i][0] <= 0 || y + D[i][0] > h || x + D[i][1] <= 0 || x + D[i][1] > w ) continue;
		if(!M[ny][nx]) continue;
		if(fvis[ny][nx]) continue;
		find_jump(ny,nx,Q, mv);
	}
}

int main(){
	int sy,sx, mv;
	scanf("%d%d",&h,&w);
	scanf("%d%d", &sy,&sx);
	scanf("%d%d", &dh,&dw);
	M = vector<vector<int>>(h+1, vector<int>(w+1));
	getchar();
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			char c;
			scanf("%c", &c);
			if(c== '.') M[i][j] = 1;
			else M[i][j] = 0;
		}
		getchar();
	}
	
	S = vector<vector<int>>(h+1, vector<int>(w+1, -1));
	vis = vector<vector<bool>>(h+1, vector<bool>(w+1, false));
	fvis = vector<vector<bool>>(h+1, vector<bool>(w+1, false));
	Qvis = vector<vector<bool>>(h+1, vector<bool>(w+1, false));
	
	queue<vector<int>> Q;
	Q.push(vector<int>({sy,sx,0}));
	while(!Q.empty()){
		sy = Q.front()[0];
		sx = Q.front()[1];
		mv = Q.front()[2];
		Q.pop();
		DFS(sy,sx,mv);
		find_jump(sy,sx,Q,mv+1);
		if(found_goal){
			printf("%d\n", answer);
			return 0;	
		}
	}
	printf("-1\n");
	
	return 0;
}


Measured memory_bytes: 12452